diff --git a/common/debugdefs.h b/common/debugdefs.h
new file mode 100644
index 0000000..8ab1885
--- /dev/null
+++ b/common/debugdefs.h
@@ -0,0 +1,29 @@
+/*
+Copyright (C) 2023 Srivats P.
+
+This file is part of "Ostinato"
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+#ifndef _DEBUG_DEFS_H
+#define _DEBUG_DEFS_H
+
+#if 0
+#define timingDebug(fmt, ...) qDebug("TIMING:" fmt, __VA_ARGS__)
+#else
+#define timingDebug(...)
+#endif
+
+#endif
diff --git a/server/pcaprxstats.cpp b/server/pcaprxstats.cpp
index 8f1daf4..ad866a2 100644
--- a/server/pcaprxstats.cpp
+++ b/server/pcaprxstats.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see
#include "pcaprxstats.h"
#include "pcapextra.h"
+#include "../common/debugdefs.h"
#include "../common/sign.h"
#include "streamtiming.h"
@@ -124,7 +125,7 @@ _skip_filter:
uint ttagId, guid;
if (SignProtocol::packetTtagId(data, hdr->caplen, &ttagId, &guid)) {
timing_->recordRxTime(portId_, guid, ttagId, hdr->ts);
- qDebug("XXXXX [%d RX] %ld:%ld ttag %u guid %u", portId_,
+ timingDebug("[%d RX] %ld:%ld ttag %u guid %u", portId_,
hdr->ts.tv_sec, long(hdr->ts.tv_usec), ttagId, guid);
}
if (guid != SignProtocol::kInvalidGuid) {
diff --git a/server/pcaptxttagstats.cpp b/server/pcaptxttagstats.cpp
index 1c357b0..ca0ddc5 100644
--- a/server/pcaptxttagstats.cpp
+++ b/server/pcaptxttagstats.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see
#include "pcaptxttagstats.h"
#include "pcapextra.h"
+#include "../common/debugdefs.h"
#include "../common/sign.h"
#include "streamtiming.h"
@@ -107,7 +108,7 @@ _skip_filter:
if (SignProtocol::packetTtagId(data, hdr->caplen,
&ttagId, &guid)) {
timing_->recordTxTime(portId_, guid, ttagId, hdr->ts);
- qDebug("XXXXX [%d TX] %ld:%ld ttag %u guid %u", portId_,
+ timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId_,
hdr->ts.tv_sec, long(hdr->ts.tv_usec), ttagId, guid);
}
break;
diff --git a/server/streamtiming.cpp b/server/streamtiming.cpp
index 790044e..dcb0c82 100644
--- a/server/streamtiming.cpp
+++ b/server/streamtiming.cpp
@@ -19,6 +19,7 @@ along with this program. If not, see
#include "streamtiming.h"
+#include "../common/debugdefs.h"
#include "timestamp.h"
#include
@@ -122,9 +123,6 @@ quint64 StreamTiming::delay(uint portId, uint guid)
if (t.countDelays == 0)
return 0;
- qDebug("XXXX [%u/%u] %lldns", portId, guid,
- timespecToNsecs(t.sumDelays)/t.countDelays);
-
return timespecToNsecs(t.sumDelays)/t.countDelays;
}
@@ -178,12 +176,12 @@ int StreamTiming::processRecords()
count++;
- qDebug("XXXXX [%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)",
+ timingDebug("[%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)",
i.value().portId, guid, i.key() & 0xFF,
diff.tv_sec, diff.tv_nsec,
rxTime.tv_sec, rxTime.tv_nsec,
txTime.tv_sec, txTime.tv_nsec);
- qDebug("XXXXX %d:[%u/%u] total %ld.%09ld count %u",
+ timingDebug("%d:[%u/%u] total %ld.%09ld count %u",
count, i.value().portId, guid,
guidTiming.sumDelays.tv_sec, guidTiming.sumDelays.tv_nsec,
guidTiming.countDelays);
@@ -219,18 +217,18 @@ int StreamTiming::deleteStaleRecords()
struct timespec txTime = i.value().timeStamp;
struct timespec diff;
timespecsub(&now, &txTime, &diff);
- qDebug("XXXX gc diff %ld", diff.tv_sec);
+ timingDebug("gc diff %ld", diff.tv_sec);
if (diff.tv_sec > 30) {
i = txHash_.erase(i);
count++;
- qDebug("XXXX -%d", count);
} else {
i++;
}
}
- qDebug("XXXX garbage collected %d stale tx timing records", count);
+ if (count)
+ qDebug("Latency garbage collected %d stale tx timing records", count);
return count;
}