]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
fwp-timing: Added -v option (verbose)
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 10 Nov 2009 10:57:47 +0000 (11:57 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 10 Nov 2009 10:57:47 +0000 (11:57 +0100)
fwp/tests/timing/fwp-timing.c

index 2db8026a45bef4832624e583fc98b5337aedc2a1..a594ef373fd123bb97b9375f3ad960317e6eeba3 100644 (file)
 #include <sys/mman.h>
 #include <semaphore.h>
 
+bool opt_verbose = false;
+
+struct stats {
+       
+} stats;
+
 void set_rt_prio(int priority)
 {
        int maxpri, minpri;
@@ -149,6 +155,7 @@ static struct option long_opts[] = {
     { "async",         0, 0, 'a' },
     { "number",        0, 0, 'n' },
     { "count", 0, 0, 'c' },
+    { "verbose",0, 0, 'v' },
     { 0, 0, 0, 0}
 };
 
@@ -164,6 +171,7 @@ usage(void)
        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");
+       printf("  -v, --verbose Be more verbose\n");
 }
 
 int parse_opts(int *argc, char **argv[], struct stream_params *p)
@@ -172,7 +180,7 @@ 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:p:s:d:n:", long_opts, NULL)) != -1) {
+       while ((opt = getopt_long(*argc, *argv, "/ab:c:p:s:d:n:v", long_opts, NULL)) != -1) {
                options_found = true;
                switch (opt) {
                case 'a':
@@ -184,18 +192,6 @@ int parse_opts(int *argc, char **argv[], struct stream_params *p)
                case 'c':
                        p->count = atoi(optarg);
                        break;
-               case 'p':
-                       p->period_ms = atoi(optarg);
-                       break;
-               case 's':
-                       ret = inet_aton(optarg, &p->src);
-                       if (!ret) {
-                               fprintf(stderr, "Source IP address not recognized: %s\n",
-                                       optarg);
-                               usage();
-                               exit(1);
-                       }
-                       break;
                case 'd':
                        ret = inet_aton(optarg, &p->dst);
                        if (!ret) {
@@ -208,6 +204,20 @@ int parse_opts(int *argc, char **argv[], struct stream_params *p)
                case 'n':
                        p->number = atoi(optarg);
                        break;
+               case 'p':
+                       p->period_ms = atoi(optarg);
+                       break;
+               case 's':
+                       ret = inet_aton(optarg, &p->src);
+                       if (!ret) {
+                               fprintf(stderr, "Source IP address not recognized: %s\n",
+                                       optarg);
+                               usage();
+                               exit(1);
+                       }
+                       break;
+               case 'v':
+                       opt_verbose = true;
                case '/':
                        break;
                default:
@@ -293,9 +303,10 @@ void *receiver(void *arg)
                clock_gettime(CLOCK_MONOTONIC, &tsr);
                tss = msg->ts;
                if (msg->cnt != last_cnt+1)
-                       printf("packet(s) lost!\n");
-               printf("%3d: %10d: %10.3lf ms\n",
-                      rp->id, msg->cnt, tsdiff2d(&tsr, &tss)*1000);
+                       printf("%3d: packet(s) lost!\n", rp->id);
+               if (opt_verbose)
+                       printf("%3d: %10d: %10.3lf ms\n",
+                              rp->id, msg->cnt, tsdiff2d(&tsr, &tss)*1000);
                last_cnt = msg->cnt;
        }
        free(rp);