From 34ca5ded72c98f4c572f40ed99178300e2bf5c74 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 1 Aug 2014 15:09:11 -0700 Subject: [PATCH 1/4] add reporting interval --- tests/jitter/src/main.cpp | 66 ++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index f93e91e5cf..ef63e3b2e1 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -18,12 +18,14 @@ #include // for MovingMinMaxAvg #include // for usecTimestampNow -void runSend(const char* addressOption, int port, int gap, int size); -void runReceive(const char* addressOption, int port, int gap, int size); +const quint64 MSEC_TO_USEC = 1000; + +void runSend(const char* addressOption, int port, int gap, int size, int report); +void runReceive(const char* addressOption, int port, int gap, int size, int report); int main(int argc, const char * argv[]) { - if (argc != 6) { - printf("usage: jitter-tests <--send|--receive>
\n"); + if (argc != 7) { + printf("usage: jitter-tests <--send|--receive>
\n"); exit(1); } const char* typeOption = argv[1]; @@ -31,9 +33,11 @@ int main(int argc, const char * argv[]) { const char* portOption = argv[3]; const char* gapOption = argv[4]; const char* sizeOption = argv[5]; + const char* reportOption = argv[6]; int port = atoi(portOption); int gap = atoi(gapOption); int size = atoi(sizeOption); + int report = atoi(reportOption); std::cout << "type:" << typeOption << "\n"; std::cout << "address:" << addressOption << "\n"; @@ -42,14 +46,14 @@ int main(int argc, const char * argv[]) { std::cout << "size:" << size << "\n"; if (strcmp(typeOption, "--send") == 0) { - runSend(addressOption, port, gap, size); + runSend(addressOption, port, gap, size, report); } else if (strcmp(typeOption, "--receive") == 0) { - runReceive(addressOption, port, gap, size); + runReceive(addressOption, port, gap, size, report); } exit(1); } -void runSend(const char* addressOption, int port, int gap, int size) { +void runSend(const char* addressOption, int port, int gap, int size, int report) { std::cout << "runSend...\n"; int sockfd; @@ -69,6 +73,7 @@ void runSend(const char* addressOption, int port, int gap, int size) { MovingMinMaxAvg timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats quint64 last = usecTimestampNow(); + quint64 lastReport = 0; while (true) { @@ -81,21 +86,25 @@ void runSend(const char* addressOption, int port, int gap, int size) { int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); - std::cout << "packet sent gap: " << actualGap << " " - << "gapDifference: " << gapDifferece << " " - << "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 (now - lastReport >= (report * MSEC_TO_USEC)) { + std::cout << "packet sent gap: " << actualGap << " " + << "gapDifference: " << gapDifferece << " " + << "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"; + lastReport = now; + } } } } -void runReceive(const char* addressOption, int port, int gap, int size) { +void runReceive(const char* addressOption, int port, int gap, int size, int report) { std::cout << "runReceive...\n"; @@ -121,6 +130,7 @@ void runReceive(const char* addressOption, int port, int gap, int size) { } quint64 last = 0; // first case + quint64 lastReport = 0; while (true) { n = recvfrom(sockfd, inputBuffer, size, 0, NULL, NULL); // we don't care about where it came from @@ -133,16 +143,20 @@ void runReceive(const char* addressOption, int port, int gap, int size) { int actualGap = now - last; int gapDifferece = actualGap - gap; timeGaps.update(gapDifferece); - std::cout << "packet received gap:" << actualGap << " " - << "gapDifference: " << gapDifferece << " " - << "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 (now - lastReport >= (report * MSEC_TO_USEC)) { + std::cout << "packet received gap:" << actualGap << " " + << "gapDifference: " << gapDifferece << " " + << "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"; + lastReport = now; + } } } } From ce46e8b812e750baf090464f1aa576f80fe5af34 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 1 Aug 2014 15:14:43 -0700 Subject: [PATCH 2/4] tweak format of report --- tests/jitter/src/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index ef63e3b2e1..bd6923330c 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -89,8 +89,7 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { - std::cout << "packet sent gap: " << actualGap << " " - << "gapDifference: " << gapDifferece << " " + std::cout << "SEND gap Difference From Expected " << "min: " << timeGaps.getMin() << " " << "max: " << timeGaps.getMax() << " " << "avg: " << timeGaps.getAverage() << " " @@ -146,8 +145,7 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo last = now; if (now - lastReport >= (report * MSEC_TO_USEC)) { - std::cout << "packet received gap:" << actualGap << " " - << "gapDifference: " << gapDifferece << " " + std::cout << "RECEIVE gap Difference From Expected " << "min: " << timeGaps.getMin() << " " << "max: " << timeGaps.getMax() << " " << "avg: " << timeGaps.getAverage() << " " From cb02ac16b6cf278929bf0aa4407e5f5f67cf1331 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 1 Aug 2014 15:23:52 -0700 Subject: [PATCH 3/4] tweak format of report --- tests/jitter/src/main.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index bd6923330c..292b01e4a5 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -70,6 +70,9 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) servaddr.sin_port=htons(port); const int SAMPLES_FOR_30_SECONDS = 30 * 1000000 / gap; + + std::cout << "SAMPLES_FOR_30_SECONDS:" << SAMPLES_FOR_30_SECONDS << "\n"; + MovingMinMaxAvg timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats quint64 last = usecTimestampNow(); @@ -90,12 +93,12 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) if (now - lastReport >= (report * MSEC_TO_USEC)) { std::cout << "SEND gap Difference From Expected " - << "min: " << timeGaps.getMin() << " " - << "max: " << timeGaps.getMax() << " " - << "avg: " << timeGaps.getAverage() << " " - << "min last 30: " << timeGaps.getWindowMin() << " " - << "max last 30: " << timeGaps.getWindowMax() << " " - << "avg last 30: " << timeGaps.getWindowAverage() << " " + << "min: " << timeGaps.getMin() << " usecs " + << "max: " << timeGaps.getMax() << " usecs " + << "avg: " << timeGaps.getAverage() << " usecs " + << "min last 30: " << timeGaps.getWindowMin() << " usecs " + << "max last 30: " << timeGaps.getWindowMax() << " usecs " + << "avg last 30: " << timeGaps.getWindowAverage() << " usecs " << "\n"; lastReport = now; } @@ -121,6 +124,9 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo myaddr.sin_port=htons(port); const int SAMPLES_FOR_30_SECONDS = 30 * 1000000 / gap; + + std::cout << "SAMPLES_FOR_30_SECONDS:" << SAMPLES_FOR_30_SECONDS << "\n"; + MovingMinMaxAvg timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { @@ -146,12 +152,12 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo if (now - lastReport >= (report * MSEC_TO_USEC)) { std::cout << "RECEIVE gap Difference From Expected " - << "min: " << timeGaps.getMin() << " " - << "max: " << timeGaps.getMax() << " " - << "avg: " << timeGaps.getAverage() << " " - << "min last 30: " << timeGaps.getWindowMin() << " " - << "max last 30: " << timeGaps.getWindowMax() << " " - << "avg last 30: " << timeGaps.getWindowAverage() << " " + << "min: " << timeGaps.getMin() << " usecs " + << "max: " << timeGaps.getMax() << " usecs " + << "avg: " << timeGaps.getAverage() << " usecs " + << "min last 30: " << timeGaps.getWindowMin() << " usecs " + << "max last 30: " << timeGaps.getWindowMax() << " usecs " + << "avg last 30: " << timeGaps.getWindowAverage() << " usecs " << "\n"; lastReport = now; } From 66d45d354419acd16f1dd45e5a358552191a01e1 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 1 Aug 2014 15:25:03 -0700 Subject: [PATCH 4/4] tweak format of report --- tests/jitter/src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index 292b01e4a5..aefed73ccf 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -93,11 +93,11 @@ void runSend(const char* addressOption, int port, int gap, int size, int report) if (now - lastReport >= (report * MSEC_TO_USEC)) { std::cout << "SEND gap Difference From Expected " - << "min: " << timeGaps.getMin() << " usecs " - << "max: " << timeGaps.getMax() << " usecs " - << "avg: " << timeGaps.getAverage() << " usecs " - << "min last 30: " << timeGaps.getWindowMin() << " usecs " - << "max last 30: " << timeGaps.getWindowMax() << " usecs " + << "min: " << timeGaps.getMin() << " usecs, " + << "max: " << timeGaps.getMax() << " usecs, " + << "avg: " << timeGaps.getAverage() << " usecs, " + << "min last 30: " << timeGaps.getWindowMin() << " usecs, " + << "max last 30: " << timeGaps.getWindowMax() << " usecs, " << "avg last 30: " << timeGaps.getWindowAverage() << " usecs " << "\n"; lastReport = now; @@ -152,11 +152,11 @@ void runReceive(const char* addressOption, int port, int gap, int size, int repo if (now - lastReport >= (report * MSEC_TO_USEC)) { std::cout << "RECEIVE gap Difference From Expected " - << "min: " << timeGaps.getMin() << " usecs " - << "max: " << timeGaps.getMax() << " usecs " - << "avg: " << timeGaps.getAverage() << " usecs " - << "min last 30: " << timeGaps.getWindowMin() << " usecs " - << "max last 30: " << timeGaps.getWindowMax() << " usecs " + << "min: " << timeGaps.getMin() << " usecs, " + << "max: " << timeGaps.getMax() << " usecs, " + << "avg: " << timeGaps.getAverage() << " usecs, " + << "min last 30: " << timeGaps.getWindowMin() << " usecs, " + << "max last 30: " << timeGaps.getWindowMax() << " usecs, " << "avg last 30: " << timeGaps.getWindowAverage() << " usecs " << "\n"; lastReport = now;