#include <semaphore.h>
#define MAX_SENDENDPOINTS 10
+#define MIN_GRANULARITY 100
unsigned opt_packet_size = 800;
unsigned opt_period_usec = 10*MSEC_TO_USEC;
unsigned opt_jitter = 0;
char *opt_output = "delay_stats";
unsigned opt_count_sec = 0;
+int opt_granularity_usec = MIN_GRANULARITY;
int ac_sockfd[AC_NUM];
/* maximal traffic delay in ms - 10 s*/
#define MAX_DELAY_US 10000000
-#define GRANULARITY 100
-unsigned delay_stats[AC_NUM][MAX_DELAY_US/GRANULARITY];
+unsigned delay_stats[AC_NUM][MAX_DELAY_US/MIN_GRANULARITY];
/*struct ac_stats[AC_NUM] {
unsigned long int min_trans_time;
void save_results()
{
int ac, i, maxi;
- const int mini = 3000/GRANULARITY;
+ const int mini = 3000/opt_granularity_usec;
bool allzeros;
unsigned sum[AC_NUM];
double val;
fprintf(stderr, "\nWriting data to %s...\n", logfname);
allzeros = true;
- for (maxi = MAX_DELAY_US/GRANULARITY - 1; maxi >= 0; maxi--) {
+ for (maxi = MAX_DELAY_US/opt_granularity_usec - 1; maxi >= 0; maxi--) {
for (ac = 0; ac < AC_NUM; ac++) {
if (delay_stats[ac][maxi] != 0) allzeros = false;
}
}
for ( i = 0 ; i < maxi; i++) {
- fprintf(logfd,"\n%f", i*GRANULARITY/1000.0);
+ fprintf(logfd,"\n%f", i*opt_granularity_usec/1000.0);
for (ac = 0; ac < AC_NUM; ac++) {
if (sum[ac])
val = (double)delay_stats[ac][i]*100.0 / sum[ac];
trans_time.tv_nsec / USEC_TO_NSEC) /2;
if (trans_time_usec < MAX_DELAY_US)
- delay_stats[ac][trans_time_usec/GRANULARITY]++;
+ delay_stats[ac][trans_time_usec/opt_granularity_usec]++;
receivers[ac].received++;
char opt;
- while ((opt = getopt(argc, argv, "c:j:o:s:")) != -1) {
+ while ((opt = getopt(argc, argv, "c:g:j:o:s:")) != -1) {
switch (opt) {
case 'c':
opt_count_sec = atoi(optarg);
break;
+ case 'g':
+ opt_granularity_usec = atoi(optarg);
+ if (opt_granularity_usec < MIN_GRANULARITY) {
+ fprintf(stderr, "Granulatiry too small (min %d)!\n", MIN_GRANULARITY);
+ exit(1);
+ }
+ break;
case 'j':
opt_jitter = atoi(optarg);
break;
fprintf(stderr, "Usage: %s [ options ] server_addr\n\n", argv[0]);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -c count (number of seconds to run)");
+ fprintf(stderr, " -g histogram granularity [usec]");
fprintf(stderr, " -j send jitter (0-100) [%%]\n");
fprintf(stderr, " -o output filename (.dat will be appended)");
fprintf(stderr, " -s size of data payload in packets [bytes]\n");