bool opt_verbose = false;
bool opt_quiet = false;
-#define HIST_MAX_US 1000000
+#define HIST_MAX_US 10000000
#define HIST_RES_US 10
struct histogram {
int count;
frsh_vres_id_t vres;
pthread_t thread;
+ int jitter;
};
{ "count", required_argument, 0, 'c' },
{ "verbose",no_argument, 0, 'v' },
{ "quiet", no_argument, 0, 'q' },
+ { "jitter", required_argument, 0, 'j' },
{ 0, 0, 0, 0}
};
printf(" -q, --quiet Print only final statistics\n");
printf(" -/, --stream New stream separator\n");
printf(" -v, --verbose Be more verbose\n");
+ printf(" -j, --jitter <percent> Sent jitter given as percentage of period\n");
}
int parse_opts(int *argc, char **argv[], struct stream_params *p)
int ret;
bool options_found = false;
- while ((opt = getopt_long(*argc, *argv, "/ab:c:d:l:n:p:qs:v", long_opts, NULL)) != -1) {
+ while ((opt = getopt_long(*argc, *argv, "/ab:c:d:j:l:n:p:qs:v", long_opts, NULL)) != -1) {
options_found = true;
switch (opt) {
case 'a':
exit(1);
}
break;
+ case 'j':
+ p->jitter = atoi(optarg);
+ break;
case 'l':
ul_log_domain_arg2levels(optarg);
break;
clock_gettime(CLOCK_MONOTONIC, &next_period);
}
__sync_fetch_and_add(&stats.sent, 1);
- next_period.tv_sec += (p->period_ms/1000);
- next_period.tv_nsec += (p->period_ms%1000) * 1000000;
+
+ int delay_ms;
+ if (p->jitter)
+ delay_ms = p->period_ms*(100-p->jitter)/100
+ + rand() % (2*p->period_ms*p->jitter/100);
+ else
+ delay_ms = p->period_ms;
+
+ next_period.tv_sec += (delay_ms/1000);
+ next_period.tv_nsec += (delay_ms%1000) * 1000000;
if (next_period.tv_nsec >= 1000000000) {
next_period.tv_nsec -= 1000000000;
next_period.tv_sec++;
printf("Sent: %5d Received: %5d Lost: %5d Max: %8.3f ms",
stats.sent, stats.received, stats.lost, hist.max/1000.0);
if (final) {
- printf(" Packetloss: %7.3f %% 90%%: %8.3f ms\n",
+ printf(" Packetloss: %7.3f %% 95%%: %8.3f ms 99%%: %8.3f ms\n",
100.0*stats.lost/stats.sent,
- hist_get_percentile(&hist, 90)/1000.0);
+ hist_get_percentile(&hist, 95)/1000.0,
+ hist_get_percentile(&hist, 99)/1000.0);
}
else
printf("\r");