]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - wme_test/wclient.c
Fixed processing when resetting statistics.
[frescor/fwp.git] / wme_test / wclient.c
1 #include <errno.h>
2 #include <sys/types.h>
3 #include <sys/socket.h>
4 #include <netinet/in.h>
5 #include <arpa/inet.h>
6 #include <netdb.h>
7 #include <signal.h>
8 #include <sys/wait.h>
9 #include <stdio.h>
10 #include <unistd.h>
11 #include <fcntl.h>
12 #include <time.h>
13 #include <string.h>
14 #include <pthread.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <stdbool.h>
18 #include "common.h"
19 #include <semaphore.h>
20
21 #define MAX_STREAMS  10 
22 #define MIN_GRANULARITY 100
23
24 unsigned opt_packet_size = 800;
25 unsigned opt_period_usec = 10*MSEC_TO_USEC;
26 unsigned opt_jitter = 0;
27 char    *opt_output = "delay_stats";
28 unsigned opt_count_sec = 0;
29 unsigned opt_def_bandwidth = 200;
30 unsigned opt_def_period_msec = 0;
31 int opt_granularity_usec = MIN_GRANULARITY;
32 bool opt_wait_for_queue_is_full; /* Don't gather any statistics until any queue is full */
33
34 bool some_queue_is_full = false;
35 struct timespec reset_timestamp;
36
37 /* Locked when some queue is full to prevent multiple resets of
38    statstics. */
39 pthread_mutex_t queue_full_mutex = PTHREAD_MUTEX_INITIALIZER;
40
41 int ac_sockfd[AC_NUM];
42
43 struct receiver {
44         pthread_t thread;
45         unsigned received, last_received;
46 } receivers[AC_NUM];
47
48 FILE* logfd;
49 char* server_addr; 
50 char logfname[100];
51
52 /* maximal traffic delay in ms - 10 s*/
53 #define MAX_DELAY_US 10000000
54
55 unsigned delay_stats[AC_NUM][MAX_DELAY_US/MIN_GRANULARITY];
56
57 /*struct ac_stats[AC_NUM] {
58    unsigned long int min_trans_time;
59    unsigned long int sum_trans_time;
60    struct timespec   recv_timestamp;
61    struct timespec   send_timestamp; 
62 };*/
63
64 struct stream {
65         /* Input parameters */
66         enum ac ac;             /*  */
67         int bandwidth_bps;      /* bits per second */
68         int jitter;             /* percent */
69         /* Mulualy exclusive input parameters */
70         int packet_size;
71         long period_usec;       /* all time units are in microseconds */
72
73         /* Statistics */
74         unsigned long long sent, received;
75 };
76
77 /*
78 struct send_endpoint sepoint[] = {
79         { .ac = AC_VO, .period_usec=200*MSEC_TO_USEC, .bandwidth_bps = 34*Kbit },
80         { .ac = AC_VI, .period_usec=25*MSEC_TO_USEC, .bandwidth_bps =  480*Kbit },
81         { .ac = AC_BE, .period_usec=40*MSEC_TO_USEC, .bandwidth_bps =  300*Kbit },
82         { .ac = AC_BK, .period_usec=40*MSEC_TO_USEC, .bandwidth_bps =  300*Kbit },
83 //      { .ac = AC_VI, .period_usec=17*MSEC_TO_USEC, .bandwidth_bps =  675*Kbit },
84 };
85 */
86
87 struct stream streams[MAX_STREAMS];
88
89 unsigned int nr_streams = 0;
90
91 sem_t sem_thread_finished;
92
93 bool exit_flag = false;
94
95 void stopper()
96 {
97         int i;
98         exit_flag = true;
99
100         /* Interrupt all receivers */
101         for (i=0; i < AC_NUM; i++) {
102                 pthread_kill(receivers[i].thread, SIGUSR1);
103         }
104 }
105
106 void stream_to_text(char *stream_desc, size_t n, struct stream *stream, int seconds)
107 {
108         char buf[3][12];
109         char real[100];
110
111         if (seconds) {
112                 snprintf(real, sizeof(real), "; real: sent %lld (%lld/s), received %lld (%lld/s)",
113                          stream->sent, stream->sent/seconds,
114                          stream->received, stream->received/seconds);
115         }
116         
117         snprintf(stream_desc, n, "%d: %s %s (%d bytes per %s +-%s, %d packets/s)%s",
118                  stream-streams, ac_to_text[stream->ac], bandwidth_to_text(buf[0], stream->bandwidth_bps),
119                  stream->packet_size, usec_to_text(buf[1], stream->period_usec),
120                  usec_to_text(buf[2], stream->jitter*stream->period_usec/100),
121                  (int)(SEC_TO_USEC/stream->period_usec), real);
122 }
123
124 void save_results(int argc, char *argv[], int seconds)
125 {
126         int ac, i, maxi;
127         const int mini = 3000/opt_granularity_usec;
128         bool allzeros;
129         unsigned sum[AC_NUM];
130         double val;
131
132         fprintf(stderr, "Writing data to %s... ", logfname);
133         fflush(stderr);
134
135         fprintf(logfd, "# Invoked as: ");
136         for (i=0; i<argc; i++) fprintf(logfd, "%s ", argv[i]);
137         fprintf(logfd, "\n");
138
139         if (seconds != opt_count_sec) {
140                 fprintf(logfd, "# Data gathered for %d seconds.\n", seconds);
141         }
142                 
143         for (i = 0; i < nr_streams; i++) {
144                 char stream_desc[120];
145                 stream_to_text(stream_desc, sizeof(stream_desc), &streams[i], seconds);
146                 fprintf(logfd, "# Stream %s\n", stream_desc);
147         }
148
149         /* Find maximal delay */
150         allzeros = true;
151         for (maxi = MAX_DELAY_US/opt_granularity_usec - 1; maxi >= 0; maxi--) {
152                 for (ac = 0; ac < AC_NUM; ac++) {
153                         if (delay_stats[ac][maxi] != 0) allzeros = false;
154                 }
155                 if (!allzeros) break;
156         }
157         maxi++;
158         if (maxi < mini) maxi = mini;
159
160         /* Calculate total number of sent packets per AC */
161         for (ac = 0; ac < AC_NUM; ac++) sum[ac] = 0;
162         for (i = 0; i < nr_streams; i++) {
163                 ac = streams[i].ac;
164                 sum[ac] += streams[i].sent;
165         }
166
167 #if 0
168         /* Write pdf */
169         for ( i = 0 ; i < maxi; i++) {
170                 fprintf(logfd,"\n%f", i*opt_granularity_usec/1000.0);
171                 for (ac = 0; ac < AC_NUM; ac++) { 
172                         if (sum[ac])
173                                 val = (double)delay_stats[ac][i]*100.0 / sum[ac];
174                         else val = -1; /* Don't display this ac */
175                         fprintf(logfd," %lf", val);
176                 }
177         }
178         
179         fprintf(logfd,"\n\n");
180 #endif
181         
182         /* Write PDF */
183         for (ac = 0; ac < AC_NUM; ac++) {
184                 unsigned long long integral = 0, last = -1;
185
186                 fprintf(logfd,"%f %f\n", 0.0, 0.0);
187
188                 if (sum[ac] != 0) {
189                         i=0;
190                         while (delay_stats[ac][i] == 0) i++;
191                 
192                         for (i++; i < maxi+1; i++) {
193                                 if (last != integral) {
194                                         val = (double)integral*100.0 / sum[ac];
195                                         fprintf(logfd,"%f %f\n", i*opt_granularity_usec/1000.0, val);
196                                         last = integral;
197                                 }
198                                 if (i>0)
199                                         integral += delay_stats[ac][i-1];
200                         }
201                 }
202                 fprintf(logfd,"\n\n");
203         }
204         
205         fprintf(stderr, "finished.\n");
206         fclose(logfd);
207
208         exit(0);
209 }
210
211 static inline 
212 void timespec_add (struct timespec *sum, const struct timespec *left,
213               const struct timespec *right)
214 {
215         sum->tv_sec = left->tv_sec + right->tv_sec;
216         sum->tv_nsec = left->tv_nsec + right->tv_nsec;
217
218         if (sum->tv_nsec >= 1000000000){
219                 ++sum->tv_sec;
220                 sum->tv_nsec -= 1000000000;
221         }
222 }
223
224 static inline 
225 void timespec_sub (struct timespec *diff, const struct timespec *left,
226               const struct timespec *right)
227 {
228         diff->tv_sec = left->tv_sec - right->tv_sec;
229         diff->tv_nsec = left->tv_nsec - right->tv_nsec;
230
231         if (diff->tv_nsec < 0){
232                   --diff->tv_sec;
233                   diff->tv_nsec += 1000000000;
234         }
235 }
236
237 int create_ac_socket(unsigned int ac) 
238 {
239         int sockfd;
240         unsigned int yes=1, tos;
241
242
243         if ((sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
244         {
245                 perror("Unable to open socket");
246                 return -1;
247         }
248         if (fcntl(sockfd, F_SETFL, O_NONBLOCK) != 0) {
249                 perror("set non-blocking socket");
250                 return -1;
251         }
252         if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
253                 perror("Unable to set socket");
254                 return -1;
255         }
256
257         
258         //tos = ((AC_NUM - ac) *2 - 1)*32;
259         tos = ac_to_tos[ac];
260         if (setsockopt(sockfd, SOL_IP, IP_TOS, &tos, sizeof(tos))) {
261                 perror("Unable to set TOS");
262                 close(sockfd);
263                 return -1;
264         }
265
266         return sockfd;
267 }
268
269 void empty_handler()
270 {
271 }
272
273 void reset_statistics()
274 {
275         int i;
276         /* Mutexes??? */
277         for (i = 0; i < nr_streams; i++) {
278                 streams[i].sent = 0;
279                 streams[i].received = 0;
280         }
281         memset(delay_stats, 0, sizeof(delay_stats));
282         clock_gettime(CLOCK_MONOTONIC, &reset_timestamp);
283 }
284
285 void* receiver(void* queue)
286 {
287         struct msg_t    msg;
288         struct  sockaddr_in rem_addr;
289         int     mlen, ret;
290         unsigned int ac, rem_addr_length; 
291         unsigned long int trans_time_usec;
292         unsigned long int min_trans_time;
293         struct timespec   send_timestamp,recv_timestamp, trans_time, time_from_reset;
294         fd_set fdset;
295         
296         min_trans_time = ~0;
297         
298         block_signals();
299         set_rt_prio(99);
300
301         ac = (int)queue;
302         rem_addr_length = sizeof(rem_addr);
303         FD_ZERO(&fdset);
304         while (!exit_flag) {
305                 FD_SET(ac_sockfd[ac], &fdset);
306                 ret = select(ac_sockfd[ac]+1, &fdset, NULL, NULL, NULL);
307                 if (ret < 0) {
308                         if (errno == EINTR) continue;
309                         perror("receiver select");
310                         goto out;
311                 }
312                 mlen = recvfrom(ac_sockfd[ac], &msg, sizeof(msg), 0,    \
313                                 (struct sockaddr*)&rem_addr, &rem_addr_length);
314                 if (mlen < 0) {
315                         perror("Chyba pri prijimani pozadavku");
316                         goto out;
317                 }       
318                 clock_gettime(CLOCK_MONOTONIC,&recv_timestamp);
319                 send_timestamp = msg.send_timestamp;
320
321                 /* Check whether this message was sent after reset_statistics() */
322                 timespec_sub(&time_from_reset, &send_timestamp, &reset_timestamp);
323                 if (time_from_reset.tv_sec < 0) {
324                         printf("ted\n");
325                         continue; /* If so, don't count it */
326                 }
327                 timespec_sub(&trans_time,&recv_timestamp ,&send_timestamp);
328                 trans_time_usec = (trans_time.tv_sec * SEC_TO_USEC + \
329                                          trans_time.tv_nsec / USEC_TO_NSEC) /2;
330           
331                 if (trans_time_usec < MAX_DELAY_US)
332                         delay_stats[ac][trans_time_usec/opt_granularity_usec]++;
333
334                 receivers[ac].received++;
335                 streams[msg.stream].received++;
336         
337                 /*if (trans_time_nsec < min_trans_time) 
338                         min_trans_time = trans_time_nsec;*/
339                 /*printf("seqn= %lu tos= %d start= %lu(s).%lu(ns)"\
340                          "stop= %lu(s).%lu(ns)\n trans_time = %lums\n",\
341                          msg.seqn, msg.tos, send_timestamp.tv_sec,\
342                          send_timestamp.tv_nsec,recv_timestamp.tv_sec,\
343                          recv_timestamp.tv_nsec, trans_time_msec); */
344         }
345 out:
346         sem_post(&sem_thread_finished);
347         return NULL;
348 }
349
350 void* sender(void* arg)
351 {
352         struct sockaddr_in rem_addr;
353         union msg_buff buff;
354         unsigned long int seqn;
355         struct timespec time_to_wait, current_time, period, interval;
356         struct hostent* ph;
357         struct stream* stream = (struct stream*) arg;
358         int packet_size;
359         unsigned period_usec;
360         char stream_desc[100];
361
362         if (stream->bandwidth_bps == 0)
363                 goto out;
364
365         set_rt_prio(90-stream->ac);
366
367         if (stream->packet_size) {
368                 packet_size = stream->packet_size;
369                 period_usec = SEC_TO_USEC*packet_size*8/stream->bandwidth_bps;
370         } else if (stream->period_usec) {
371                 period_usec = stream->period_usec;
372                 packet_size = (long long)stream->bandwidth_bps/8 * period_usec/SEC_TO_USEC;
373         } else {
374                 char buf[200];
375                 stream_to_text(buf, sizeof(buf), stream, 0);
376                 fprintf(stderr, "Neither packet size nor period was specified for a stream %s\n", buf);
377                 exit(1);
378         }
379         stream->packet_size = packet_size;
380         stream->period_usec = period_usec;
381         stream->jitter = opt_jitter;
382
383
384         stream_to_text(stream_desc, sizeof(stream_desc), stream, 0);
385
386         printf("%s\n", stream_desc);
387
388         if (packet_size < sizeof(struct msg_t)) {
389                 fprintf(stderr, "Packet size too small (min %d)\n", sizeof(struct msg_t));
390                 exit(1);
391         }
392
393         
394         memset(&rem_addr,0, sizeof(rem_addr));
395                 
396         rem_addr.sin_family = AF_INET;
397         ph = gethostbyname(server_addr);
398         if (ph) 
399                 rem_addr.sin_addr = *((struct in_addr *)ph->h_addr);
400         else {
401                 perror("Unknown server");
402                 exit(1);
403         }
404         rem_addr.sin_port = htons(BASE_PORT + stream->ac);
405         seqn = 0;
406         
407         block_signals();
408
409         while (!exit_flag) {
410
411                 buff.msg.seqn = seqn;
412                 buff.msg.tos = ac_to_tos[stream->ac];
413                 buff.msg.stream = stream-streams;
414                 
415                 clock_gettime(CLOCK_MONOTONIC,&buff.msg.send_timestamp);
416
417                 while (sendto(ac_sockfd[stream->ac], &buff, packet_size, 0,\
418                                 (struct sockaddr*)&rem_addr, sizeof(rem_addr)) < 0) {
419                                 if (errno == EINTR) continue;
420                                 if (errno == EAGAIN) {
421                                         if (!some_queue_is_full && (pthread_mutex_trylock(&queue_full_mutex) != EBUSY)) {
422                                                 some_queue_is_full = true;
423                                                 reset_statistics();
424                                         }
425
426                                         break;
427                                 } else {
428                                         perror("Error while sending");
429                                         goto out;
430                                 }
431                 }
432
433 #ifdef DEBUG
434                 printf("%d", ac);
435                 fflush(stdout);
436 #endif
437                 seqn++;
438                 stream->sent++;
439
440                 /*           |~~~+~~~| jitter interval (width = 2*opt_jitter percentage from period)*/
441                 /* |-------------|     nominal period*/
442                 if (opt_jitter) {
443                         period.tv_nsec = USEC_TO_NSEC*(period_usec*(100-opt_jitter)/100
444                                                  + rand() % (2*period_usec*opt_jitter/100));
445                 } else {
446                         period.tv_nsec = USEC_TO_NSEC*(period_usec);
447                 }
448                 period.tv_sec = 0;
449
450                 timespec_add(&time_to_wait,&buff.msg.send_timestamp,&period);
451                 clock_gettime(CLOCK_MONOTONIC,&current_time);
452                 timespec_sub(&interval,&time_to_wait,&current_time);
453                 nanosleep(&interval,NULL);
454         }
455 out:
456         sem_post(&sem_thread_finished);
457         return NULL;
458 }
459
460 char* parse_bandwidths(char *params)
461 {
462         struct stream *sp = &streams[nr_streams];
463
464         while (*params && nr_streams < MAX_STREAMS) {
465                 char *ac_ids[AC_NUM] = { [AC_VO]="VO", [AC_VI]="VI", [AC_BE]="BE", [AC_BK]="BK" };
466                 int i;
467                 char *next_char;
468
469                 if (strlen(params) < 2)
470                         return params;
471                 for (i=0; i<AC_NUM; i++) {
472                         if (strncmp(params, ac_ids[i], 2) == 0) {
473                                 sp->ac = i;
474                                 params+=strlen(ac_ids[i]);
475                                 break;
476                         }
477                 }
478                 if (i==AC_NUM)
479                         return params;
480
481                 long bw;
482                 if (*params == ':') {
483                         params++;
484
485                         bw = strtol(params, &next_char, 10);
486                         if (next_char == params)
487                                 return params;
488                         params = next_char;
489                 } else
490                         bw = opt_def_bandwidth;
491                 
492                 sp->bandwidth_bps = bw*Kbit;
493
494                 long period = 0;
495                 long packet_size = 0;
496                 if (*params == '@') {
497                         params++;
498                         period = strtol(params, &next_char, 10);
499                         if (period == 0)
500                                 return params;
501                         params = next_char;
502                 }
503                 else {
504                         if (*params == '/') {
505                                 params++;
506                                 packet_size = strtol(params, &next_char, 10);
507                                 if (packet_size == 0)
508                                         return params;
509                                 params = next_char;
510                         } else {
511                                 packet_size = opt_packet_size;
512                                 period = opt_def_period_msec;
513                         }
514                 }
515                 sp->period_usec = period*MSEC_TO_USEC;
516                 sp->packet_size = packet_size;
517
518                 
519
520                 if (*params != '\0' && *params != ',')
521                         return params;
522                 nr_streams++;
523                 sp++;
524                 if (*params == ',')
525                         params++;
526         }
527         return NULL;
528 }
529
530 int main(int argc, char *argv[])
531 {
532         int ac, i, rc, seconds, seconds_start;
533         pthread_attr_t attr;
534         pthread_t thread;
535         char opt;
536
537
538         while ((opt = getopt(argc, argv, "B:b:c:g:j:o:qs:T:")) != -1) {
539                 switch (opt) {
540                         case 'B':
541                                 opt_def_bandwidth = atoi(optarg);
542                                 break;
543                         case 'b': {
544                                 char *error;
545                                 error = parse_bandwidths(optarg);
546                                 if (error != NULL) {
547                                         if (*error == '\0')
548                                                 fprintf(stderr, "Bandwidth parse error - string to short\n");
549                                         else
550                                                 fprintf(stderr, "Bandwidth parse error at '%s'\n", error);
551                                         exit(1);
552                                 }
553                                 break;
554                         }
555                         case 'c':
556                                 opt_count_sec = atoi(optarg);
557                                 break;
558                         case 'g':
559                                 opt_granularity_usec = atoi(optarg);
560                                 if (opt_granularity_usec < MIN_GRANULARITY) {
561                                         fprintf(stderr, "Granulatiry too small (min %d)!\n", MIN_GRANULARITY);
562                                         exit(1);
563                                 }
564                                 break;
565                         case 'j':
566                                 opt_jitter = atoi(optarg);
567                                 break;
568                         case 'o':
569                                 opt_output = optarg;
570                                 break;
571                         case 'q':
572                                 opt_wait_for_queue_is_full = true;
573                                 break;
574                         case 's':
575                                 opt_packet_size = atoi(optarg);
576                                 break;
577                         case 'T':
578                                 opt_def_period_msec = atoi(optarg);
579                                 break;
580                         default:
581                                 fprintf(stderr, "Usage: %s [ options ] server_addr\n\n", argv[0]);
582                                 fprintf(stderr, "Options:\n");
583                                 fprintf(stderr, "    -B  default bandwidth for -b option [kbit]\n");
584                                 fprintf(stderr, "    -b  bandwidth of streams (VO|VI|BE|BK)[:<kbit>][@<msec> or /<bytes>][,...]\n");
585                                 fprintf(stderr, "    -c  count (number of seconds to run)\n");
586                                 fprintf(stderr, "    -g  histogram granularity [usec]\n");
587                                 fprintf(stderr, "    -j  send jitter (0-100) [%%]\n");
588                                 fprintf(stderr, "    -o  output filename (.dat will be appended)\n");
589                                 fprintf(stderr, "    -q  gather statistics only after some queue becomes full\n");
590                                 fprintf(stderr, "    -s  size of data payload in packets [bytes] (default: %d)\n", opt_packet_size);
591                                 fprintf(stderr, "    -T  default period for -b option [msec]\n");
592                                 exit(1);
593                 }
594         }
595         if (opt_packet_size && opt_def_period_msec) {
596                 fprintf(stderr, "Error: Nonzero -T and -s can't be used together!.\n");
597                 exit(1);
598         }
599
600         if (optind < argc) {
601                 server_addr = argv[optind];
602         } else {
603                 fprintf(stderr, "Expected server address argument\n");
604                 exit(1);
605         }
606
607
608         if (nr_streams == 0)
609                 parse_bandwidths("BE");
610                 
611         memset(delay_stats,0, sizeof(delay_stats));     
612         pthread_attr_init(&attr);
613
614         snprintf(logfname, sizeof(logfname), "%s.dat", opt_output);
615
616         if ((logfd = fopen(logfname,"w+")) == NULL) {
617                 fprintf(stderr,"Can not open %s\n", logfname);
618                 exit(1);
619         }
620         if (signal(SIGTERM, stopper) == SIG_ERR) {
621                 perror("Error in signal registration");
622                 exit(1);
623         }
624                 
625         if (signal(SIGINT, stopper) == SIG_ERR) {
626                 perror("Signal handler registration error");
627                 exit(1);
628         }
629
630         struct sigaction sa;
631         sa.sa_handler = empty_handler;
632         sa.sa_flags = 0;        /* don't restart syscalls */
633
634         if (sigaction(SIGUSR1, &sa, NULL) < 0) {
635                 perror("sigaction error");
636                 exit(1);
637         }
638
639         sem_init(&sem_thread_finished, 0, 0);
640
641         /* create four receivers each per AC */
642         for (ac = AC_NUM - 1; ac >= 0; ac--) {
643                 ac_sockfd[ac] = create_ac_socket(ac);
644                 rc = pthread_create(&receivers[ac].thread, &attr, receiver, (void*) ac);
645                 if (rc) {
646                         fprintf(stderr, "Error while creating receiver %d\n",rc);
647                         return 1;
648                 }
649         }               
650                         
651         /* create sendpoints */
652         for (i = 0; i < nr_streams; i++) {
653                 rc = pthread_create(&thread, &attr, sender, (void*) &streams[i]);
654                 if (rc) {
655                         fprintf(stderr, "Error while creating sender %d\n",rc);
656                         return 1;
657                 }
658         }
659         
660         seconds = 0;
661         seconds_start = -1;
662         while (!exit_flag) {
663                 sleep(1);
664                 seconds++;
665                 if (opt_wait_for_queue_is_full) {
666                         if (some_queue_is_full && seconds_start == -1) {
667                                 printf("\nSome queue is full\n");
668                                 seconds_start = seconds;
669                         }
670                 }
671                 fprintf(stderr, "\r%3ds", seconds);
672                 for (ac = 0; ac < AC_NUM; ac++) {
673                         int delta = receivers[ac].received - receivers[ac].last_received;
674                         receivers[ac].last_received = receivers[ac].received;
675                         fprintf(stderr, " %s %5d %4d/s", ac_to_text[ac], receivers[ac].received, delta);
676                 }
677                 fflush(stderr);
678                 if (seconds == opt_count_sec)
679                         stopper();
680         }
681
682         fprintf(stderr, "\nWaiting for threads to finish\n");
683         /* Wait for all threads to finish */
684         for (i=0; i < nr_streams + AC_NUM; i++) {
685                 sem_wait(&sem_thread_finished);
686         }
687
688         if (seconds_start == -1) seconds_start=0;
689         save_results(argc, argv, seconds-seconds_start);
690
691         return 0;
692 }