From 2941c7ec22fe645c4e320ef454a7398e049e23a8 Mon Sep 17 00:00:00 2001 From: Srivats P Date: Tue, 20 Jun 2023 11:59:56 +0530 Subject: [PATCH] Fix crash for top speed tx with ttag in seq mode Crash was due to loopDelay being 0 in case of topSpeed. For ttags, we recalculatue loopDelay based on max line rate and avg pkt size. The problem doesn't exist in interleaved mode because minGap and duration are non-zero in the top speed tx case. --- common/packet.h | 1 + server/abstractport.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/common/packet.h b/common/packet.h index 5d8609e..adf5562 100644 --- a/common/packet.h +++ b/common/packet.h @@ -78,6 +78,7 @@ const quint16 kIp4EthType = 0x0800; const quint16 kIp6EthType = 0x86dd; const quint16 kMplsEthType = 0x8847; const QSet kVlanEthTypes = {0x8100, 0x9100, 0x88a8}; +const uint kEthOverhead = 20; // VLAN const quint16 kVlanTagSize = 4; diff --git a/server/abstractport.cpp b/server/abstractport.cpp index f97c2dd..9bad48e 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -21,6 +21,7 @@ along with this program. If not, see #include "../common/abstractprotocol.h" #include "../common/framevalueattrib.h" +#include "../common/packet.h" #include "../common/streambase.h" #include "devicemanager.h" #include "interfaceinfo.h" @@ -400,6 +401,18 @@ int AbstractPort::updatePacketListSequential() } } + // loopDelay == 0 implies 0 pps i.e. top speed + // For ttag calc/config below we need loopDelay to be non-zero, + // so we re-calc based on max line rate (speed). If we don't + // have the actual port speed, we assume 1000 Mbps + if (loopDelay == 0) { + double maxSpeed = data_.speed() ? data_.speed(): 1000; + double maxPktRate = (maxSpeed*1e6) + /(8*(streamList_[i]->frameLenAvg() + + Packet::kEthOverhead)); + loopDelay = 1e9/maxPktRate; // in nanosec + } + // Add a Ttag marker after every kTtagTimeInterval_ worth of pkts if (hasTtag) { uint ttagPktInterval = kTtagTimeInterval_*1e9/loopDelay; @@ -638,6 +651,7 @@ int AbstractPort::updatePacketListInterleaved() // i.e. send all streams "simultaneously" as fast as possible // as a result all streams will be at the same rate e.g. for 2 streams, // it would 50% each; for 3 streams - all at 33.3% and so on + // FIXME: Should we calc minGap based on max line rate and avg pkt size? if (minGap == ULLONG_MAX) { minGap = 1; duration = 1;