From 8c14f948f2ea3f917293699cf3d17afcd2f10465 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 1 Aug 2014 13:15:57 -0700 Subject: [PATCH] handle first packet stats better --- tests/jitter/src/main.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index f3d2960d2d..a44bb3bef1 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -123,23 +123,28 @@ void runReceive(const char* addressOption, int port, int gap, int size) { return; } - quint64 last = usecTimestampNow(); + quint64 last = 0; // first case while (true) { n = recvfrom(sockfd, inputBuffer, size, 0, NULL, NULL); // we don't care about where it came from - - quint64 now = usecTimestampNow(); - int actualGap = now - last; - timeGaps.update(actualGap); - std::cout << "packet received gap:" << actualGap << " " - << "min:" << timeGaps.getMin() << " " - << "max:" << timeGaps.getMax() << " " - << "avg:" << timeGaps.getAverage() << " " - << "min last 30:" << timeGaps.getWindowMin() << " " - << "max last 30:" << timeGaps.getWindowMax() << " " - << "avg last 30:" << timeGaps.getWindowAverage() << " " - << "\n"; - last = now; + + if (last == 0) { + last = usecTimestampNow(); + std::cout << "first packet received\n"; + } else { + quint64 now = usecTimestampNow(); + int actualGap = now - last; + timeGaps.update(actualGap); + std::cout << "packet received gap:" << actualGap << " " + << "min:" << timeGaps.getMin() << " " + << "max:" << timeGaps.getMax() << " " + << "avg:" << timeGaps.getAverage() << " " + << "min last 30:" << timeGaps.getWindowMin() << " " + << "max last 30:" << timeGaps.getWindowMax() << " " + << "avg last 30:" << timeGaps.getWindowAverage() << " " + << "\n"; + last = now; + } } }