diff --git a/src/iperf_api.c b/src/iperf_api.c index 4eb10d3..40a9474 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1163,6 +1163,11 @@ void iperf_run_client(struct iperf_test *test) }// while outer timer + // for last interval + test->stats_callback(test); + read = test->reporter_callback(test); + puts(read); + // sending STREAM_END packets sp = test->streams; np = sp; diff --git a/src/timer.c b/src/timer.c index 38166df..a5decb2 100644 --- a/src/timer.c +++ b/src/timer.c @@ -9,41 +9,62 @@ #include "timer.h" + + +double timeval_to_double(struct timeval *tv) +{ + double d; + + d = tv->tv_sec + tv->tv_usec /1000000; + + return d; +} + + +double timeval_diff(struct timeval *tv0, struct timeval *tv1) +{ + return timeval_to_double(tv1) - timeval_to_double(tv0); +} + +/* int timer_expired(struct timer *tp) { struct timeval now; + double d= 0; if(gettimeofday(&now, NULL) < 0) { perror("gettimeofday"); return -1; } - - return tp->end.tv_sec <= now.tv_sec; + + d = timeval_to_double(&tp->end) - timeval_to_double(&now); + + return d <= 0; } +*/ int -timer_expired_micro(struct timer *tp) +timer_expired(struct timer *tp) { struct timeval now; - int64_t diff= 0, current= 0; + int64_t end = 0, current= 0, diff= 0; if(gettimeofday(&now, NULL) < 0) { perror("gettimeofday"); return -1; } - diff+= tp->end.tv_sec * 1000000 ; - diff+= tp->end.tv_usec; + end+= tp->end.tv_sec * 1000000 ; + end+= tp->end.tv_usec; current+= now.tv_sec * 1000000 ; current+= now.tv_usec; - return diff <= current; + diff = end - current; + return diff <= 0; - // currently using microsecond limit. Else we need to introduce timespec instread of timeval -} - + } struct timer * @@ -60,12 +81,9 @@ new_timer(time_t sec, suseconds_t usec) memcpy(&tp->end, &tp->begin, sizeof(struct timer)); tp->end.tv_sec = tp->begin.tv_sec + (time_t) sec; tp->end.tv_usec = tp->begin.tv_usec + (time_t) usec; + + tp->expired = timer_expired; - if( sec != 0) - tp->expired = timer_expired; - else - tp->expired = timer_expired_micro; - return tp; } @@ -100,20 +118,3 @@ delay(int64_t ns) } -double timeval_to_double(struct timeval *tv) -{ - double d; - - d = tv->tv_sec + tv->tv_usec /1000000; - - return d; -} - - -double timeval_diff(struct timeval *tv0, struct timeval *tv1) -{ - return timeval_to_double(tv1) - timeval_to_double(tv0); -} - - -