Rework sequential mode build for new ttag algo

The previous commit changed the algo to determine which packets were Ttag'd,
but changes were done only for interleaved mode.

This commit adds the changes required for sequential mode.
This commit is contained in:
Srivats P 2023-04-24 17:05:40 +05:30
parent ef1c166e7f
commit 4394c7ffee
2 changed files with 25 additions and 4 deletions

View File

@ -235,6 +235,9 @@ int AbstractPort::updatePacketList()
int AbstractPort::updatePacketListSequential() int AbstractPort::updatePacketListSequential()
{ {
quint64 duration = 0; // in nanosec
quint64 totalPkts = 0;
QList<uint> ttagMarkers;
FrameValueAttrib packetListAttrib; FrameValueAttrib packetListAttrib;
long sec = 0; long sec = 0;
long nsec = 0; long nsec = 0;
@ -262,6 +265,8 @@ int AbstractPort::updatePacketListSequential()
quint64 npy1 = 0, npy2 = 0; quint64 npy1 = 0, npy2 = 0;
quint64 loopDelay; quint64 loopDelay;
ulong frameVariableCount = streamList_[i]->frameVariableCount(); ulong frameVariableCount = streamList_[i]->frameVariableCount();
bool hasTtag = streamList_[i]->hasProtocol(
OstProto::Protocol::kSignFieldNumber);
// We derive n, x, y such that // We derive n, x, y such that
// n * x + y = total number of packets to be sent // n * x + y = total number of packets to be sent
@ -334,6 +339,7 @@ int AbstractPort::updatePacketListSequential()
else if (n == 0) else if (n == 0)
x = 0; x = 0;
quint64 pktCount = n*x + y;
for (uint j = 0; j < (x+y); j++) for (uint j = 0; j < (x+y); j++)
{ {
@ -386,6 +392,15 @@ int AbstractPort::updatePacketListSequential()
} }
} }
// Add a Ttag marker after every kTtagTimeInterval_ worth of pkts
if (hasTtag) {
uint ttagPktInterval = kTtagTimeInterval_*1e9/loopDelay;
for (uint k = 0; k < pktCount; k += ttagPktInterval)
ttagMarkers.append(totalPkts + k);
}
totalPkts += pktCount;
duration += pktCount*loopDelay; // in nanosecs
switch(streamList_[i]->nextWhat()) switch(streamList_[i]->nextWhat())
{ {
case StreamBase::e_nw_stop: case StreamBase::e_nw_stop:
@ -423,6 +438,10 @@ int AbstractPort::updatePacketListSequential()
_out_of_memory: _out_of_memory:
_stop_no_more_pkts: _stop_no_more_pkts:
// See comments in updatePacketListInterleaved() for calc explanation
setPacketListTtagMarkers(ttagMarkers, ttagMarkers.isEmpty() ? 0 :
qMax(uint(kTtagTimeInterval_*1e9/(duration)),
1U) * totalPkts);
isSendQueueDirty_ = false; isSendQueueDirty_ = false;
qDebug("PacketListAttrib = %x", qDebug("PacketListAttrib = %x",
@ -633,7 +652,7 @@ int AbstractPort::updatePacketListInterleaved()
// TODO: Find less expensive way to do this counting // TODO: Find less expensive way to do this counting
// FIXME: Turbo still thinks it has to create implicit packet set for // FIXME: Turbo still thinks it has to create implicit packet set for
// interleaved mode - Turbo code should be changed once this is validated // interleaved mode - Turbo code should be changed once this is validated
qint64 totalPkts = 0; quint64 totalPkts = 0;
QSet<int> ttagMarkerStreams; QSet<int> ttagMarkerStreams;
QList<uint> ttagMarkers; QList<uint> ttagMarkers;
do do
@ -645,6 +664,8 @@ int AbstractPort::updatePacketListInterleaved()
continue; continue;
// One marker per stream // One marker per stream
// TODO: We should have a marker every 5s per stream if
// the pktList is > 5s
if (hasTtag.at(i) && !ttagMarkerStreams.contains(i)) { if (hasTtag.at(i) && !ttagMarkerStreams.contains(i)) {
ttagMarkerStreams.insert(i); ttagMarkerStreams.insert(i);
ttagMarkers.append(totalPkts); ttagMarkers.append(totalPkts);

View File

@ -155,13 +155,13 @@ int StreamTiming::processRecords()
count++; count++;
qDebug("XXXXX [%u/%u/%u] diff %ld.%ld (%ld.%ld - %ld.%ld)", qDebug("XXXXX [%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)",
i.value().portId, guid, i.key() & 0xFF, i.value().portId, guid, i.key() & 0xFF,
diff.tv_sec, diff.tv_nsec, diff.tv_sec, diff.tv_nsec,
rxTime.tv_sec, rxTime.tv_nsec, rxTime.tv_sec, rxTime.tv_nsec,
txTime.tv_sec, txTime.tv_nsec); txTime.tv_sec, txTime.tv_nsec);
qDebug("XXXXX %d:[%u/%u] total %ld.%ld count %u", qDebug("XXXXX %d:[%u/%u] total %ld.%09ld count %u",
count, i.value().portId, i.key(), count, i.value().portId, guid,
guidTiming.sumDelays.tv_sec, guidTiming.sumDelays.tv_nsec, guidTiming.sumDelays.tv_sec, guidTiming.sumDelays.tv_nsec,
guidTiming.countDelays); guidTiming.countDelays);
} }