struct in_addr src, dst;
int number;
int id;
+ int count;
};
{ "dest", 1, 0, 'd' },
{ "async", 0, 0, 'a' },
{ "number", 0, 0, 'n' },
+ { "count", 0, 0, 'c' },
{ 0, 0, 0, 0}
};
printf(" -d, --dest <ip:port> destination IP address and port\n");
printf(" -a, --async Send packets asynchronously\n");
printf(" -n, --number Number of streams with the same parameters\n");
+ printf(" -c, --count Number of messages to send [infinity]\n");
printf(" -/, --stream New stream separator\n");
}
int ret;
bool options_found = false;
- while ((opt = getopt_long(*argc, *argv, "/ab:p:s:d:n:", long_opts, NULL)) != -1) {
+ while ((opt = getopt_long(*argc, *argv, "/ab:c:p:s:d:n:", long_opts, NULL)) != -1) {
options_found = true;
switch (opt) {
case 'a':
case 'b':
p->budget = atoi(optarg);
break;
+ case 'c':
+ p->count = atoi(optarg);
+ break;
case 'p':
p->period_ms = atoi(optarg);
break;
struct timespec next_period;
struct timespec tss;
clock_gettime(CLOCK_MONOTONIC, &next_period);
- while (!exit_flag) {
+ while (!exit_flag && (p->count == -1 || p->count--)) {
clock_gettime(CLOCK_MONOTONIC, &tss);
msg->cnt = cnt++;
msg->ts = tss;
.src.s_addr = htonl(INADDR_LOOPBACK),
.dst.s_addr = htonl(INADDR_LOOPBACK),
.number = 1,
+ .count = -1,
};
struct stream_params *p = NULL;