From e6e81d61e8a11fa4561bf61ddbb146e6ea8b0e53 Mon Sep 17 00:00:00 2001 From: Samuel Jero Date: Mon, 22 Oct 2012 23:53:29 -0400 Subject: [PATCH] Actually add CCID selection ability --- include/Locale.h | 6 ++++++ include/Reporter.h | 1 + include/Settings.hpp | 1 + include/headers.h | 3 ++- src/Locale.c | 10 ++++++++++ src/PerfSocket.cpp | 8 ++++++++ src/ReportDefault.c | 15 ++++++++++++--- src/Reporter.c | 1 + src/Settings.cpp | 11 ++++++++++- 9 files changed, 51 insertions(+), 5 deletions(-) diff --git a/include/Locale.h b/include/Locale.h index 5365016..3769ae8 100644 --- a/include/Locale.h +++ b/include/Locale.h @@ -93,6 +93,12 @@ extern const char window_default[]; extern const char wait_server_threads[]; +extern const char dccp_byte_stream_mode[]; + +extern const char dccp_ccid_default[]; + +extern const char dccp_ccid_val[]; + /* ------------------------------------------------------------------- * reports * ------------------------------------------------------------------- */ diff --git a/include/Reporter.h b/include/Reporter.h index 1dbb22c..01fda0c 100644 --- a/include/Reporter.h +++ b/include/Reporter.h @@ -129,6 +129,7 @@ typedef struct ReporterData { int mBufLen; // -l int mMSS; // -M int mWinSize; // -w + int mCCID; //-Z /* flags is a BitMask of old bools bool mBufLenSet; // -l bool mCompat; // -C diff --git a/include/Settings.hpp b/include/Settings.hpp index d4c4244..6383f48 100644 --- a/include/Settings.hpp +++ b/include/Settings.hpp @@ -160,6 +160,7 @@ typedef struct thread_Settings { int mBufLen; // -l int mMSS; // -M int mWinSize; // -w + int mCCID; // -Z /* flags is a BitMask of old bools bool mBufLenSet; // -l bool mCompat; // -C diff --git a/include/headers.h b/include/headers.h index 05d05c3..cebabf5 100644 --- a/include/headers.h +++ b/include/headers.h @@ -166,7 +166,8 @@ typedef uintmax_t max_size_t; /* UDP-Lite specific definitions and includes */ #ifdef IPPROTO_UDPLITE -#include +/*#include Ubuntu doesn't have this header*/ +#include "udplite.h" #else #define IPPROTO_UDPLITE 136 #define SOL_UDPLITE 136 diff --git a/src/Locale.c b/src/Locale.c index cd05ba5..8c5ca16 100644 --- a/src/Locale.c +++ b/src/Locale.c @@ -88,6 +88,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\ + -Z, --ccid # Set DCCP congestion control algorithm\n\ \n\ Server specific:\n\ -s, --server run in server mode\n\ @@ -172,6 +173,15 @@ const char window_default[] = const char wait_server_threads[] = "Waiting for server threads to complete. Interrupt again to force quit.\n"; +const char dccp_byte_stream_mode[]= +"NOTE: running in bytestream-mode (maximum speed)\n"; + +const char dccp_ccid_default[]= +"CCID: (default)\n"; + +const char dccp_ccid_val[]= +"CCID: %i\n"; + /* ------------------------------------------------------------------- * reports * ------------------------------------------------------------------- */ diff --git a/src/PerfSocket.cpp b/src/PerfSocket.cpp index 1c3a779..de88a75 100644 --- a/src/PerfSocket.cpp +++ b/src/PerfSocket.cpp @@ -156,6 +156,14 @@ void SetSocketOptions( thread_Settings *inSettings ) rc = setsockopt( inSettings->mSock, SOL_DCCP, DCCP_SOCKOPT_SERVICE, &val, len ); WARN_errno( rc == SOCKET_ERROR, "setsockopt DCCP_SOCKOPT_SERVICE" ); + + if(inSettings->mCCID!=0){ + char cv=inSettings->mCCID; + rc=setsockopt( inSettings->mSock, SOL_DCCP, DCCP_SOCKOPT_CCID, + &cv, sizeof(cv)); + + WARN_errno( rc == SOCKET_ERROR, "Error Setting CCID"); + } } // UDP-Lite specific options if ( inSettings->mProtocol == kProto_UDPLITE ) { diff --git a/src/ReportDefault.c b/src/ReportDefault.c index 150df10..8287efd 100644 --- a/src/ReportDefault.c +++ b/src/ReportDefault.c @@ -161,7 +161,7 @@ void reporter_reportsettings( ReporterData *data ) { data->mThreadMode != kMode_Listener); win_requested = data->mWinSize; - printf( seperator_line ); + printf(seperator_line); if ( data->mThreadMode == kMode_Listener ) { printf( server_port, protoName(data->mProtocol), @@ -185,8 +185,17 @@ void reporter_reportsettings( ReporterData *data ) { data->mBufLen ); if (SockAddr_isMulticast((struct sockaddr *)&data->connection.peer)) printf( multicast_ttl, data->info.mTTL); - } else if (data->mProtocol == kProto_DCCP) - printf("NOTE: running in bytestream-mode (maximum speed)\n"); + } else if (data->mProtocol == kProto_DCCP){ + printf(dccp_byte_stream_mode); + } + + if (data->mProtocol == kProto_DCCP){ + if(data->mCCID==0){ + printf(dccp_ccid_default); + }else{ + printf(dccp_ccid_val,data->mCCID); + } + } byte_snprintf( buffer, sizeof(buffer), win, toupper( data->info.mFormat)); diff --git a/src/Reporter.c b/src/Reporter.c index f3bd219..27bb259 100644 --- a/src/Reporter.c +++ b/src/Reporter.c @@ -450,6 +450,7 @@ void ReportSettings( thread_Settings *agent ) { data->info.congAlgo = agent->congAlgo; data->connection.peer = agent->peer; data->connection.local = agent->local; + data->mCCID=agent->mCCID; #ifdef HAVE_THREAD /* diff --git a/src/Settings.cpp b/src/Settings.cpp index 3cb619f..42c21a2 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -124,6 +124,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'}, +{"ccid", required_argument, NULL, 'Z'}, {0, 0, 0, 0} }; @@ -169,13 +170,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_CCID", required_argument, NULL, 'Z'}, {0, 0, 0, 0} }; #define SHORT_OPTIONS() const char short_options[] = - "12b::c:df:hi:j:l:mn:o:p:rst:u::vw:x:y:A:B:CDF:IJ:L:M:NP:RS:T:UV:W"; + "12b::c:df:hi:j:l:mn:o:p:rst:uvw:x:y:A:B:CDF:IJ:L:M:NP:RS:T:UV:WZ:"; /* ------------------------------------------------------------------- * defaults @@ -669,6 +671,13 @@ void Settings_Interpret( char option, const char *optarg, thread_Settings *mExtS fprintf( stderr, "The -W option is not available in this release\n"); break; + case 'Z': //DCCP CCID + mExtSettings->mCCID=atoi(optarg); + if(mExtSettings->mCCID > 255 || mExtSettings->mCCID<=0){ + fprintf( stderr, "CCID %s is invalid\n", optarg); + } + break; + default: // ignore unknown break; } -- 2.39.2