add dataChannelCount option

This commit is contained in:
Murat Dogan
2021-04-10 19:48:10 +03:00
parent a48f080605
commit 8190188a05
2 changed files with 18 additions and 3 deletions

View File

@ -51,6 +51,7 @@ Cmdline::Cmdline(int argc, char *argv[]) // ISO C++17 not allowed: throw (std::s
{"enableThroughputSet", no_argument, NULL, 'p'},
{"throughtputSetAsKB", required_argument, NULL, 'r'},
{"bufferSize", required_argument, NULL, 'b'},
{"dataChannelCount", required_argument, NULL, 'c'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};
@ -68,9 +69,10 @@ Cmdline::Cmdline(int argc, char *argv[]) // ISO C++17 not allowed: throw (std::s
_p = false;
_r = 300;
_b = 0;
_c = 1;
optind = 0;
while ((c = getopt_long(argc, argv, "s:t:w:x:d:r:b:enhvop", long_options, &optind)) != -1) {
while ((c = getopt_long(argc, argv, "s:t:w:x:d:r:b:c:enhvop", long_options, &optind)) != -1) {
switch (c) {
case 'n':
_n = true;
@ -147,6 +149,15 @@ Cmdline::Cmdline(int argc, char *argv[]) // ISO C++17 not allowed: throw (std::s
}
break;
case 'c':
_c = atoi(optarg);
if (_c <= 0) {
std::string err;
err += "parameter range error: c must be > 0";
throw(std::range_error(err));
}
break;
case 'h':
_h = true;
this->usage(EXIT_SUCCESS);
@ -196,6 +207,8 @@ libdatachannel client implementing WebRTC Data Channels with WebSocket signaling
Send a constant data per second (KB). See throughtputSetAsKB params.\n\
[ -r ] [ --throughtputSetAsKB ] (type=INTEGER, range>0...INT_MAX, default=300)\n\
Send constant data per second (KB).\n\
[ -c ] [ --dataChannelCount ] (type=INTEGER, range>0...INT_MAX, default=1)\n\
Dat Channel count to create.\n\
[ -h ] [ --help ] (type=FLAG)\n\
Display this help and exit.\n";
}

View File

@ -45,6 +45,7 @@ private:
bool _p;
int _r;
int _b;
int _c;
/* other stuff to keep track of */
std::string _program_name;
@ -69,9 +70,10 @@ public:
bool h () const { return _h; }
int durationInSec () const { return _d; }
bool noSend () const { return _o; }
int bufferSize() const { return _b;}
int bufferSize() const { return _b; }
bool enableThroughputSet () const { return _p; }
int throughtputSetAsKB() const { return _r;}
int throughtputSetAsKB() const { return _r; }
int dataChannelCount() const { return _c; }
};
#endif