diff -uprN -X dontdiff iperf-2.0.2/include/PerfSocket.hpp iperf-2.0.2-dccp/include/PerfSocket.hpp --- iperf-2.0.2/include/PerfSocket.hpp2005-05-03 08:09:26.000000000 +1200 +++ iperf-2.0.2-dccp/include/PerfSocket.hpp2005-11-01 15:49:42.000000000 +1300 @@ -59,7 +59,10 @@ #include "Mutex.h" #include "Settings.hpp" - void SetSocketOptions( thread_Settings *inSettings ); + void MakeSocket( thread_Settings *inSettings ); + + void SetTCPSocketOptions( thread_Settings *inSettings ); + void SetDCCPSocketOptions( thread_Settings *inSettings ); // handle interupts void Sig_Interupt( int inSigno ); diff -uprN -X dontdiff iperf-2.0.2/include/Reporter.h iperf-2.0.2-dccp/include/Reporter.h --- iperf-2.0.2/include/Reporter.h2005-05-03 08:09:26.000000000 +1200 +++ iperf-2.0.2-dccp/include/Reporter.h2005-11-01 14:22:06.000000000 +1300 @@ -145,6 +145,7 @@ typedef struct ReporterData { bool mUDP; bool mMode_time;*/ int flags; + Protocol mProtocol; // enums (which should be special int's) ThreadMode mThreadMode; // -s or -c ReportMode mode; diff -uprN -X dontdiff iperf-2.0.2/include/Settings.hpp iperf-2.0.2-dccp/include/Settings.hpp --- iperf-2.0.2/include/Settings.hpp2005-05-03 08:09:26.000000000 +1200 +++ iperf-2.0.2-dccp/include/Settings.hpp2005-11-01 13:51:24.000000000 +1300 @@ -94,6 +94,13 @@ typedef enum TestMode { kTest_Unknown } TestMode; +typedef enum Protocol { + kTCP = 0, + kUDP, + kDCCP, + kSCTP +} Protocol; + #include "Reporter.h" /* * The thread_Settings is a structure that holds all @@ -148,12 +155,13 @@ typedef struct thread_Settings { bool mNoMultReport; // -x m bool mSinlgeClient; // -1 */ int flags; + Protocol mProtocol; // enums (which should be special int's) ThreadMode mThreadMode; // -s or -c ReportMode mReportMode; TestMode mMode; // -r or -d // Hopefully int64_t's - max_size_t mUDPRate; // -b or -u + max_size_t mRate; // -b or -u max_size_t mAmount; // -n or -t // doubles double mInterval; // -i @@ -197,7 +205,7 @@ typedef struct thread_Settings { #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 @@ -208,6 +216,8 @@ typedef struct thread_Settings { #define FLAG_NOMULTREPORT 0x00080000 #define FLAG_SINGLECLIENT 0x00100000 #define FLAG_SINGLEUDP 0x00200000 +#define FLAG_CONNECTIONLESS 0x00400000 +#define FLAG_PACKETORIENTED 0x08000000 #define isBuflenSet(settings) ((settings->flags & FLAG_BUFLENSET) != 0) #define isCompat(settings) ((settings->flags & FLAG_COMPAT) != 0) @@ -220,7 +230,6 @@ typedef struct thread_Settings { #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) @@ -233,6 +242,8 @@ typedef struct thread_Settings { // end Active Low #define isSingleClient(settings) ((settings->flags & FLAG_SINGLECLIENT) != 0) #define isSingleUDP(settings) ((settings->flags & FLAG_SINGLEUDP) != 0) +#define isConnectionLess(settings) ((settings->flags & FLAG_CONNECTIONLESS) != 0) +#define isPacketOriented(settings) ((settings->flags & FLAG_PACKETORIENTED) != 0) #define setBuflenSet(settings) settings->flags |= FLAG_BUFLENSET #define setCompat(settings) settings->flags |= FLAG_COMPAT @@ -245,7 +256,6 @@ typedef struct thread_Settings { #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 @@ -256,6 +266,8 @@ typedef struct thread_Settings { #define setNoMultReport(settings) settings->flags |= FLAG_NOMULTREPORT #define setSingleClient(settings) settings->flags |= FLAG_SINGLECLIENT #define setSingleUDP(settings) settings->flags |= FLAG_SINGLEUDP +#define setConnectionLess(settings) settings->flags |= FLAG_CONNECTIONLESS +#define setPacketOriented(settings) settings->flags |= FLAG_PACKETORIENTED #define unsetBuflenSet(settings) settings->flags &= ~FLAG_BUFLENSET #define unsetCompat(settings) settings->flags &= ~FLAG_COMPAT @@ -268,7 +280,6 @@ typedef struct thread_Settings { #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 @@ -279,6 +290,8 @@ typedef struct thread_Settings { #define unsetNoMultReport(settings) settings->flags &= ~FLAG_NOMULTREPORT #define unsetSingleClient(settings) settings->flags &= ~FLAG_SINGLECLIENT #define unsetSingleUDP(settings) settings->flags &= ~FLAG_SINGLEUDP +#define unsetConnectionLess(settings) settings->flags &= ~FLAG_CONNECTIONLESS +#define unsetPacketOriented(settings) settings->flags &= ~FLAG_PACKETORIENTED #define HEADER_VERSION1 0x80000000 diff -uprN -X dontdiff iperf-2.0.2/include/util.h iperf-2.0.2-dccp/include/util.h --- iperf-2.0.2/include/util.h2005-05-03 08:09:26.000000000 +1200 +++ iperf-2.0.2-dccp/include/util.h2005-10-28 14:53:46.000000000 +1300 @@ -53,6 +53,8 @@ #ifndef UTIL_H #define UTIL_H +#define SOCK_DCCP 6 + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff -uprN -X dontdiff iperf-2.0.2/src/Client.cpp iperf-2.0.2-dccp/src/Client.cpp --- iperf-2.0.2/src/Client.cpp2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/Client.cpp2005-11-01 15:48:51.000000000 +1300 @@ -140,14 +140,14 @@ void Client::Run( void ) { mEndTime.add( mSettings->mAmount / 100.0 ); } - if ( isUDP( mSettings ) ) { + if ( isPacketOriented( mSettings ) ) { // Due to the UDP timestamps etc, included // reduce the read size by an amount // equal to the header size // compute delay for bandwidth restriction, constrained to [0,1] seconds delay_target = (int) ( mSettings->mBufLen * ((kSecs_to_usecs * kBytes_to_Bits) - / mSettings->mUDPRate) ); + / mSettings->mRate) ); if ( delay_target < 0 || delay_target > (int) 1 * kSecs_to_usecs ) { fprintf( stderr, warn_delay_large, delay_target / kSecs_to_usecs ); @@ -187,7 +187,7 @@ void Client::Run( void ) { //} gettimeofday( &(reportstruct->packetTime), NULL ); - if ( isUDP( mSettings ) ) { + if ( isPacketOriented( mSettings ) ) { // store datagram ID into buffer mBuf_UDP->id = htonl( (reportstruct->packetID)++ ); mBuf_UDP->tv_sec = htonl( reportstruct->packetTime.tv_sec ); @@ -239,7 +239,7 @@ void Client::Run( void ) { gettimeofday( &(reportstruct->packetTime), NULL ); CloseReport( mSettings->reporthdr, reportstruct ); - if ( isUDP( mSettings ) ) { + if ( isPacketOriented( mSettings ) ) { // send a final terminating datagram // Don't count in the mTotalLen. The server counts this one, // but didn't count our first datagram, so we're even now. @@ -265,14 +265,15 @@ void Client::InitiateServer() { if ( !isCompat( mSettings ) ) { int currLen; client_hdr* temp_hdr; - if ( isUDP( mSettings ) ) { + + if ( isPacketOriented( mSettings ) ) { UDP_datagram *UDPhdr = (UDP_datagram *)mBuf; temp_hdr = (client_hdr*)(UDPhdr + 1); } else { temp_hdr = (client_hdr*)mBuf; } Settings_GenerateClientHdr( mSettings, temp_hdr ); - if ( !isUDP( mSettings ) ) { + if ( !isConnectionLess( mSettings ) ) { currLen = send( mSettings->mSock, mBuf, sizeof(client_hdr), 0 ); if ( currLen < 0 ) { WARN_errno( currLen < 0, "write1" ); @@ -291,23 +292,15 @@ void Client::Connect( ) { int rc; SockAddr_remoteAddr( mSettings ); - assert( mSettings->inHostname != NULL ); - - // create an internet socket - int type = ( isUDP( mSettings ) ? SOCK_DGRAM : SOCK_STREAM); - - int domain = (SockAddr_isIPv6( &mSettings->peer ) ? -#ifdef HAVE_IPV6 - AF_INET6 -#else - AF_INET -#endif - : AF_INET); +// assert( mSettings->inHostname != NULL ); - mSettings->mSock = socket( domain, type, 0 ); - WARN_errno( mSettings->mSock == INVALID_SOCKET, "socket" ); + MakeSocket( mSettings); - SetSocketOptions( mSettings ); +if (mSettings->mProtocol == kTCP) { + SetTCPSocketOptions( mSettings ); +} else if (mSettings->mProtocol == kDCCP) { +SetDCCPSocketOptions( mSettings); +} SockAddr_localAddr( mSettings ); diff -uprN -X dontdiff iperf-2.0.2/src/Listener.cpp iperf-2.0.2-dccp/src/Listener.cpp --- iperf-2.0.2/src/Listener.cpp2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/Listener.cpp2005-11-01 15:49:01.000000000 +1300 @@ -137,11 +137,12 @@ void Listener::Run( void ) { #endif #endif { - bool client = false, UDP = isUDP( mSettings ), mCount = (mSettings->mThreads != 0); + bool client = false, mCount = (mSettings->mThreads != 0); thread_Settings *tempSettings = NULL; Iperf_ListEntry *exist, *listtemp; - client_hdr* hdr = ( UDP ? (client_hdr*) (((UDP_datagram*)mBuf) + 1) : - (client_hdr*) mBuf); + client_hdr* hdr = isPacketOriented(mSettings) + ? (client_hdr*) (((UDP_datagram*)mBuf) + 1) + : (client_hdr*) mBuf; if ( mSettings->mHost != NULL ) { client = true; @@ -185,7 +186,7 @@ void Listener::Run( void ) { (sockaddr*) &server->peer ) ) { // Not allowed try again close( server->mSock ); - if ( isUDP( mSettings ) ) { + if ( isConnectionLess( mSettings ) ) { mSettings->mSock = -1; Listen(); } @@ -221,7 +222,7 @@ void Listener::Run( void ) { tempSettings = NULL; if ( !isCompat( mSettings ) && !isMulticast( mSettings ) ) { - if ( !UDP ) { +if ( isConnectionLess (mSettings) ) { // TCP does not have the info yet if ( recv( server->mSock, (char*)hdr, sizeof(client_hdr), 0) > 0 ) { Settings_GenerateClientSettings( server, &tempSettings, @@ -249,7 +250,7 @@ void Listener::Run( void ) { // Start the server #if defined(WIN32) && defined(HAVE_THREAD) - if ( UDP ) { + if ( isConnectionLess(mSettings) ) { // WIN32 does bad UDP handling so run single threaded if ( server->runNow != NULL ) { thread_start( server->runNow ); @@ -263,7 +264,7 @@ void Listener::Run( void ) { thread_start( server ); // create a new socket - if ( UDP ) { + if ( isConnectionLess(mSettings) ) { mSettings->mSock = -1; Listen( ); } @@ -293,30 +294,13 @@ void Listener::Listen( ) { SockAddr_localAddr( mSettings ); - // create an internet TCP socket - int type = (isUDP( mSettings ) ? SOCK_DGRAM : SOCK_STREAM); - int domain = (SockAddr_isIPv6( &mSettings->local ) ? -#ifdef HAVE_IPV6 - AF_INET6 -#else - AF_INET -#endif - : AF_INET); - -#ifdef WIN32 - if ( SockAddr_isMulticast( &mSettings->local ) ) { - // Multicast on Win32 requires special handling - mSettings->mSock = WSASocket( domain, type, 0, 0, 0, WSA_FLAG_MULTIPOINT_C_LEAF | WSA_FLAG_MULTIPOINT_D_LEAF ); - WARN_errno( mSettings->mSock == INVALID_SOCKET, "socket" ); - - } else -#endif - { - mSettings->mSock = socket( domain, type, 0 ); - WARN_errno( mSettings->mSock == INVALID_SOCKET, "socket" ); - } + MakeSocket( mSettings ); - SetSocketOptions( mSettings ); +if (mSettings->mProtocol == kTCP) { + SetTCPSocketOptions( mSettings ); +} else if (mSettings->mProtocol == kDCCP) { +SetDCCPSocketOptions( mSettings); +} // reuse the address, so we can run if a former server was killed off int boolean = 1; @@ -337,7 +321,7 @@ void Listener::Listen( ) { } // listen for connections (TCP only). // default backlog traditionally 5 - if ( !isUDP( mSettings ) ) { + if ( !isConnectionLess( mSettings ) ) { rc = listen( mSettings->mSock, 5 ); WARN_errno( rc == SOCKET_ERROR, "listen" ); } @@ -416,7 +400,7 @@ void Listener::McastSetTTL( int val ) { void Listener::Accept( thread_Settings *server ) { server->size_peer = sizeof(iperf_sockaddr); - if ( isUDP( server ) ) { + if ( isConnectionLess(server)) { /* ------------------------------------------------------------------- * Do the equivalent of an accept() call for UDP sockets. This waits * on a listening UDP socket until we get a datagram. @@ -465,13 +449,14 @@ void Listener::Accept( thread_Settings * void Listener::UDPSingleServer( ) { - bool client = false, UDP = isUDP( mSettings ), mCount = (mSettings->mThreads != 0); + bool client = false, mCount = (mSettings->mThreads != 0); thread_Settings *tempSettings = NULL; Iperf_ListEntry *exist, *listtemp; int rc; int32_t datagramID; - client_hdr* hdr = ( UDP ? (client_hdr*) (((UDP_datagram*)mBuf) + 1) : - (client_hdr*) mBuf); + client_hdr* hdr = isPacketOriented(mSettings) + ? (client_hdr*) (((UDP_datagram*)mBuf) + 1) + : (client_hdr*) mBuf; ReportStruct *reportstruct = new ReportStruct; if ( mSettings->mHost != NULL ) { diff -uprN -X dontdiff iperf-2.0.2/src/Locale.c iperf-2.0.2-dccp/src/Locale.c --- iperf-2.0.2/src/Locale.c2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/Locale.c2005-11-01 16:32:41.000000000 +1300 @@ -90,6 +90,7 @@ Client/Server:\n\ -M, --mss # set TCP maximum segment size (MTU - 40 bytes)\n\ -N, --nodelay set TCP no delay, disabling Nagle's Algorithm\n\ -V, --IPv6Version Set the domain to IPv6\n\ + -X, --protocol set protcol: TCP, UDP, DCCP, SCTP\n\ \n\ Server specific:\n\ -s, --server run in server mode\n\ @@ -186,7 +187,7 @@ Report bugs to \n"; #endif const char version[] = -"iperf version " IPERF_VERSION " (" IPERF_VERSION_DATE ") " IPERF_THREADS "\n"; +"iperf version " IPERF_VERSION "-dccp-01-Nov-05 (" IPERF_VERSION_DATE ") " IPERF_THREADS "\n"; /* ------------------------------------------------------------------- * settings diff -uprN -X dontdiff iperf-2.0.2/src/PerfSocket.cpp iperf-2.0.2-dccp/src/PerfSocket.cpp --- iperf-2.0.2/src/PerfSocket.cpp2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/PerfSocket.cpp2005-11-01 16:23:41.000000000 +1300 @@ -78,12 +78,60 @@ #include "SocketAddr.h" #include "util.h" +// create an internet socket +void MakeSocket(thread_Settings *inSettings) { +int domain = +#ifdef HAVE_IPV6 +SockAddr_isIPv6(&inSettings->local) ? AF_INET6 : +#endif + AF_INET; + int type = 0, proto = 0; + + switch (inSettings->mProtocol) { + case kTCP: + type = SOCK_STREAM; + break; + +case kUDP: + type = SOCK_DGRAM; + setPacketOriented(inSettings); + setConnectionLess(inSettings); + break; + + case kSCTP: + type = SOCK_STREAM; + proto = IPPROTO_SCTP; + break; + + case kDCCP: + type = SOCK_DCCP; +// setPacketOriented(inSettings); + break; + +default: + fprintf(stderr, "Don't understand the protocol '%s'\n", +inSettings->mProtocol); + } + +#ifdef WIN32 + if ( SockAddr_isMulticast( &mSettings->local ) ) { + // Multicast on Win32 requires special handling + inSettings->mSock = WSASocket( domain, type, proto, 0, 0, + WSA_FLAG_MULTIPOINT_C_LEAF | WSA_FLAG_MULTIPOINT_D_LEAF ); + + } else +#endif + inSettings->mSock = socket( domain, type, proto ); + + WARN_errno( inSettings->mSock == INVALID_SOCKET, "socket" ); +} + /* ------------------------------------------------------------------- * Set socket options before the listen() or connect() calls. * These are optional performance tuning factors. * ------------------------------------------------------------------- */ -void SetSocketOptions( thread_Settings *inSettings ) { +void SetTCPSocketOptions( thread_Settings *inSettings ) { // set the TCP window size (socket buffer sizes) // also the UDP buffer size // must occur before call to accept() for large window sizes @@ -123,7 +171,7 @@ void SetSocketOptions( thread_Settings * } #endif - if ( !isUDP( inSettings ) ) { + if ( !isPacketOriented( inSettings ) ) { // set the TCP maximum segment size setsock_tcp_mss( inSettings->mSock, inSettings->mMSS ); @@ -140,4 +188,19 @@ void SetSocketOptions( thread_Settings * #endif } } -// end SetSocketOptions +// end SetTCPSocketOptions +// +// +#define SOL_DCCP 269 +#define DCCP_SOCKOPT_SERVICE 2 + +void SetDCCPSocketOptions( thread_Settings *inSettings ) { +char *dummy_svc = "junk"; +Socklen_t len = sizeof(dummy_svc); +int rc; + +rc = setsockopt( inSettings->mSock, SOL_DCCP, DCCP_SOCKOPT_SERVICE, + (char*) &dummy_svc, len ); +WARN_errno( rc, "SetDCCPSocketOptions" ); +} +// end SetDCCPSocketOptions diff -uprN -X dontdiff iperf-2.0.2/src/ReportDefault.c iperf-2.0.2-dccp/src/ReportDefault.c --- iperf-2.0.2/src/ReportDefault.c2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/ReportDefault.c2005-11-01 15:21:43.000000000 +1300 @@ -145,21 +145,39 @@ void reporter_serverstats( Connection_In */ void reporter_reportsettings( ReporterData *data ) { int win, win_requested; + char *protocol; win = getsock_tcp_windowsize( data->info.transferID, (data->mThreadMode == kMode_Listener ? 0 : 1) ); win_requested = data->mTCPWin; printf( seperator_line ); + switch (data->mProtocol) { + case kTCP: + protocol = "TCP"; + break; + + case kUDP: + protocol = "UDP"; + break; + + case kDCCP: + protocol = "DCCP"; + break; + + case kSCTP: + protocol = "SCTP"; + break; + + default: + protocol = "unknown"; + break; + } + if ( data->mThreadMode == kMode_Listener ) { - printf( server_port, - (isUDP( data ) ? "UDP" : "TCP"), - data->mPort ); +printf( server_port, protocol, data->mPort ); } else { - printf( client_port, - data->mHost, - (isUDP( data ) ? "UDP" : "TCP"), - data->mPort ); +printf( client_port, data->mHost, protocol, data->mPort ); } if ( data->mLocalhost != NULL ) { printf( bind_address, data->mLocalhost ); @@ -168,7 +186,7 @@ void reporter_reportsettings( ReporterDa } } - if ( isUDP( data ) ) { + if ( isConnectionLess( data ) ) { printf( (data->mThreadMode == kMode_Listener ? server_datagram_size : client_datagram_size), data->mBufLen ); @@ -178,7 +196,7 @@ void reporter_reportsettings( ReporterDa } byte_snprintf( buffer, sizeof(buffer), win, toupper( data->info.mFormat)); - printf( "%s: %s", (isUDP( data ) ? + printf( "%s: %s", (isPacketOriented( data ) ? udp_buffer_size : tcp_window_size), buffer ); if ( win_requested == 0 ) { diff -uprN -X dontdiff iperf-2.0.2/src/Reporter.c iperf-2.0.2-dccp/src/Reporter.c --- iperf-2.0.2/src/Reporter.c2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/Reporter.c2005-10-28 14:53:46.000000000 +1300 @@ -157,11 +157,12 @@ MultiHeader* InitMulti( thread_Settings data->mMSS = agent->mMSS; data->mTCPWin = agent->mTCPWin; data->flags = agent->flags; +data->mProtocol = agent->mProtocol; data->mThreadMode = agent->mThreadMode; data->mode = agent->mReportMode; data->info.mFormat = agent->mFormat; data->info.mTTL = agent->mTTL; - if ( isUDP( agent ) ) { + if ( isConnectionLess( agent ) ) { multihdr->report->info.mUDP = (char)agent->mThreadMode; } if ( isConnectionReport( agent ) ) { @@ -238,11 +239,12 @@ ReportHeader* InitReport( thread_Setting data->mMSS = agent->mMSS; data->mTCPWin = agent->mTCPWin; data->flags = agent->flags; + data->mProtocol = agent->mProtocol; data->mThreadMode = agent->mThreadMode; data->mode = agent->mReportMode; data->info.mFormat = agent->mFormat; data->info.mTTL = agent->mTTL; - if ( isUDP( agent ) ) { + if ( isPacketOriented( agent ) ) { reporthdr->report.info.mUDP = (char)agent->mThreadMode; } } else { @@ -443,6 +445,7 @@ void ReportSettings( thread_Settings *ag data->mMSS = agent->mMSS; data->mTCPWin = agent->mTCPWin; data->flags = agent->flags; + data->mProtocol = agent->mProtocol; data->mThreadMode = agent->mThreadMode; data->mPort = agent->mPort; data->info.mFormat = agent->mFormat; @@ -786,7 +789,7 @@ int reporter_condprintstats( ReporterDat if ( stats->info.cntError > stats->info.cntOutofOrder ) { stats->info.cntError -= stats->info.cntOutofOrder; } - stats->info.cntDatagrams = (isUDP(stats) ? stats->PacketID : stats->cntDatagrams); + stats->info.cntDatagrams = (isPacketOriented(stats) ? stats->PacketID : stats->cntDatagrams); stats->info.TotalLen = stats->TotalLen; stats->info.startTime = 0; stats->info.endTime = TimeDifference( stats->packetTime, stats->startTime ); @@ -808,9 +811,9 @@ int reporter_condprintstats( ReporterDat stats->info.cntError -= stats->info.cntOutofOrder; } stats->lastError = stats->cntError; - stats->info.cntDatagrams = (isUDP( stats ) ? stats->PacketID - stats->lastDatagrams : + stats->info.cntDatagrams = (isPacketOriented( stats ) ? stats->PacketID - stats->lastDatagrams : stats->cntDatagrams - stats->lastDatagrams); - stats->lastDatagrams = (isUDP( stats ) ? stats->PacketID : stats->cntDatagrams); + stats->lastDatagrams = (isPacketOriented( stats ) ? stats->PacketID : stats->cntDatagrams); stats->info.TotalLen = stats->TotalLen - stats->lastTotal; stats->lastTotal = stats->TotalLen; stats->info.startTime = stats->info.endTime; @@ -833,7 +836,7 @@ int reporter_print( ReporterData *stats, switch ( type ) { case TRANSFER_REPORT: statistics_reports[stats->mode]( &stats->info ); - if ( end != 0 && isPrintMSS( stats ) && !isUDP( stats ) ) { + if ( end != 0 && isPrintMSS( stats ) && !isPacketOriented( stats ) ) { PrintMSS( stats ); } break; diff -uprN -X dontdiff iperf-2.0.2/src/Server.cpp iperf-2.0.2-dccp/src/Server.cpp --- iperf-2.0.2/src/Server.cpp2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/Server.cpp2005-10-28 14:53:46.000000000 +1300 @@ -110,7 +110,7 @@ void Server::Run( void ) { // perform read currLen = recv( mSettings->mSock, mBuf, mSettings->mBufLen, 0 ); - if ( isUDP( mSettings ) ) { + if ( isPacketOriented( mSettings ) ) { // read the datagram ID and sentTime out of the buffer reportstruct->packetID = ntohl( mBuf_UDP->id ); reportstruct->sentTime.tv_sec = ntohl( mBuf_UDP->tv_sec ); @@ -134,7 +134,7 @@ void Server::Run( void ) { CloseReport( mSettings->reporthdr, reportstruct ); // send a acknowledgement back only if we're NOT receiving multicast - if ( isUDP( mSettings ) && !isMulticast( mSettings ) ) { + if ( isConnectionLess( mSettings ) && !isMulticast( mSettings ) ) { // send back an acknowledgement of the terminating datagram write_UDP_AckFIN( ); } diff -uprN -X dontdiff iperf-2.0.2/src/Settings.cpp iperf-2.0.2-dccp/src/Settings.cpp --- iperf-2.0.2/src/Settings.cpp2005-05-03 08:09:27.000000000 +1200 +++ iperf-2.0.2-dccp/src/Settings.cpp2005-11-01 16:47:26.000000000 +1300 @@ -120,6 +120,7 @@ const struct option long_options[] = {"single_udp", no_argument, NULL, 'U'}, {"ipv6_domian", no_argument, NULL, 'V'}, {"suggest_win_size", no_argument, NULL, 'W'}, +{"protocol", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; @@ -162,12 +163,14 @@ const struct option env_options[] = {"IPERF_SINGLE_UDP", no_argument, NULL, 'U'}, {"IPERF_IPV6_DOMAIN", no_argument, NULL, 'V'}, {"IPERF_SUGGEST_WIN_SIZE", required_argument, NULL, 'W'}, +{"IPERF_PROTOCOL", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; #define SHORT_OPTIONS() -const char short_options[] = "1b:c:df:hi:l:mn:o:p:rst:uvw:x:y:B:CDF:IL:M:NP:RS:T:UVW"; +const char short_options[] = +"1b:c:df:hi:l:mn:o:p:rst:uvw:x:y:B:CDF:IL:M:NP:RS:T:UVWX:"; /* ------------------------------------------------------------------- * defaults @@ -206,6 +209,7 @@ void Settings_Initialize( thread_Setting // mAmount is time also // -n, N/A //main->mOutputFileName = NULL; // -o, filename main->mPort = 5001; // -p, ttcp port + main->mProtocol= kTCP, // -q, default to TCP // mMode = kTest_Normal; // -r, mMode == kTest_TradeOff main->mThreadMode = kMode_Unknown; // -s, or -c, none main->mAmount = 1000; // -t, 10 seconds @@ -315,8 +319,9 @@ void Settings_Interpret( char option, co setSingleClient( mExtSettings ); break; case 'b': // UDP bandwidth - if ( !isUDP( mExtSettings ) ) { + if ( !isPacketOriented( mExtSettings ) ) { fprintf( stderr, warn_implied_udp, option ); +mExtSettings->mProtocol = kUDP; } if ( mExtSettings->mThreadMode != kMode_Client ) { @@ -325,8 +330,7 @@ void Settings_Interpret( char option, co } Settings_GetLowerCaseArg(optarg,outarg); - mExtSettings->mUDPRate = byte_atoi(outarg); - setUDP( mExtSettings ); + mExtSettings->mRate = byte_atoi(outarg); // if -l has already been processed, mBufLenSet is true // so don't overwrite that value. @@ -394,7 +398,7 @@ void Settings_Interpret( char option, co Settings_GetUpperCaseArg(optarg,outarg); mExtSettings->mBufLen = byte_atoi( outarg ); setBuflenSet( mExtSettings ); - if ( !isUDP( mExtSettings ) ) { + if ( !isPacketOriented( mExtSettings ) ) { if ( mExtSettings->mBufLen < (int) sizeof( client_hdr ) && !isCompat( mExtSettings ) ) { setCompat( mExtSettings ); @@ -466,9 +470,9 @@ void Settings_Interpret( char option, co case 'u': // UDP instead of TCP // if -b has already been processed, UDP rate will // already be non-zero, so don't overwrite that value - if ( !isUDP( mExtSettings ) ) { - setUDP( mExtSettings ); - mExtSettings->mUDPRate = kDefault_UDPRate; + if (mExtSettings->mProtocol != kUDP) { +mExtSettings->mProtocol = kUDP; + mExtSettings->mRate = kDefault_UDPRate; } // if -l has already been processed, mBufLenSet is true @@ -664,29 +668,40 @@ void Settings_Interpret( char option, co fprintf( stderr, "The -W option is not available in this release\n"); break; +case 'X': + Settings_GetUpperCaseArg( optarg, outarg ); + if (strcmp(outarg,"TCP") == 0) + mExtSettings->mProtocol = kTCP; + else if (strcmp(outarg,"UDP") == 0) + mExtSettings->mProtocol = kUDP; + else if (strcmp(outarg,"DCCP") == 0) + mExtSettings->mProtocol = kDCCP; + else if (strcmp(outarg,"SCTP") == 0) + mExtSettings->mProtocol = kSCTP; + else + fprintf( stderr, "%s is not a valid protocol for -X\n", +optarg); + break; + default: // ignore unknown break; } } // end Interpret void Settings_GetUpperCaseArg(const char *inarg, char *outarg) { - - int len = strlen(inarg); - strcpy(outarg,inarg); - - if ( (len > 0) && (inarg[len-1] >='a') - && (inarg[len-1] <= 'z') ) - outarg[len-1]= outarg[len-1]+'A'-'a'; + while (*inarg) { + *outarg++ = islower(*inarg) ? toupper(*inarg) : *inarg; + ++inarg; + } + *outarg = '\0'; } void Settings_GetLowerCaseArg(const char *inarg, char *outarg) { - - int len = strlen(inarg); - strcpy(outarg,inarg); - - if ( (len > 0) && (inarg[len-1] >='A') - && (inarg[len-1] <= 'Z') ) - outarg[len-1]= outarg[len-1]-'A'+'a'; + while (*inarg) { + *outarg++ = isupper(*inarg) ? tolower(*inarg) : *inarg; + ++inarg; + } + *outarg = '\0'; } /* @@ -752,8 +767,8 @@ void Settings_GenerateClientSettings( th (*client)->mBufLen = ntohl(hdr->bufferlen); } if ( hdr->mWinBand != 0 ) { - if ( isUDP( server ) ) { - (*client)->mUDPRate = ntohl(hdr->mWinBand); + if ( isPacketOriented( server ) ) { + (*client)->mRate = ntohl(hdr->mWinBand); } else { (*client)->mTCPWin = ntohl(hdr->mWinBand); } @@ -812,8 +827,8 @@ void Settings_GenerateClientHdr( thread_ } else { hdr->bufferlen = 0; } - if ( isUDP( client ) ) { - hdr->mWinBand = htonl(client->mUDPRate); + if ( isPacketOriented( client ) ) { + hdr->mWinBand = htonl(client->mRate); } else { hdr->mWinBand = htonl(client->mTCPWin); }