mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Merge pull request #3244 from ZappoMan/jittertesttool
updated formatting added reporting interval to quiet the noise
This commit is contained in:
commit
d86f6c42b2
1 changed files with 44 additions and 26 deletions
|
@ -18,12 +18,14 @@
|
|||
#include <MovingMinMaxAvg.h> // for MovingMinMaxAvg
|
||||
#include <SharedUtil.h> // 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> <address> <port> <gap in ms> <packet size>\n");
|
||||
if (argc != 7) {
|
||||
printf("usage: jitter-tests <--send|--receive> <address> <port> <gap in usecs> <packet size> <report interval in msecs>\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;
|
||||
|
@ -66,9 +70,13 @@ void runSend(const char* addressOption, int port, int gap, int size) {
|
|||
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<int> timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats
|
||||
|
||||
quint64 last = usecTimestampNow();
|
||||
quint64 lastReport = 0;
|
||||
|
||||
while (true) {
|
||||
|
||||
|
@ -81,21 +89,24 @@ 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 << "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, "
|
||||
<< "avg last 30: " << timeGaps.getWindowAverage() << " usecs "
|
||||
<< "\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";
|
||||
|
||||
|
||||
|
@ -113,6 +124,9 @@ void runReceive(const char* addressOption, int port, int gap, int size) {
|
|||
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<int> timeGaps(1, SAMPLES_FOR_30_SECONDS); // stats
|
||||
|
||||
if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) {
|
||||
|
@ -121,6 +135,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 +148,19 @@ 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 << "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, "
|
||||
<< "avg last 30: " << timeGaps.getWindowAverage() << " usecs "
|
||||
<< "\n";
|
||||
lastReport = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue