sign: Calculate stream stats only if configured
Stream Stats Rx and Tx both are calculated only if 'Track Stream Stats' is configured on the port
This commit is contained in:
parent
028843c55a
commit
35c56b9181
@ -27,7 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
class PacketSequence
|
class PacketSequence
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketSequence() {
|
PacketSequence(bool trackGuidStats) {
|
||||||
|
trackGuidStats_ = trackGuidStats;
|
||||||
sendQueue_ = pcap_sendqueue_alloc(1*1024*1024);
|
sendQueue_ = pcap_sendqueue_alloc(1*1024*1024);
|
||||||
lastPacket_ = NULL;
|
lastPacket_ = NULL;
|
||||||
packets_ = 0;
|
packets_ = 0;
|
||||||
@ -61,7 +62,7 @@ public:
|
|||||||
lastPacket_ = (struct pcap_pkthdr *)
|
lastPacket_ = (struct pcap_pkthdr *)
|
||||||
(sendQueue_->buffer + sendQueue_->len);
|
(sendQueue_->buffer + sendQueue_->len);
|
||||||
ret = pcap_sendqueue_queue(sendQueue_, pktHeader, pktData);
|
ret = pcap_sendqueue_queue(sendQueue_, pktHeader, pktData);
|
||||||
if (ret >= 0) {
|
if (trackGuidStats_ && (ret >= 0)) {
|
||||||
uint guid;
|
uint guid;
|
||||||
if (SignProtocol::packetGuid(pktData, pktHeader->caplen, &guid)) {
|
if (SignProtocol::packetGuid(pktData, pktHeader->caplen, &guid)) {
|
||||||
streamStatsMeta_[guid].tx_pkts++;
|
streamStatsMeta_[guid].tx_pkts++;
|
||||||
@ -79,6 +80,9 @@ public:
|
|||||||
int repeatSize_;
|
int repeatSize_;
|
||||||
long usecDelay_;
|
long usecDelay_;
|
||||||
StreamStats streamStatsMeta_;
|
StreamStats streamStatsMeta_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool trackGuidStats_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -132,12 +132,32 @@ bool PcapPort::setRateAccuracy(AbstractPort::Accuracy accuracy)
|
|||||||
|
|
||||||
bool PcapPort::startStreamStatsTracking()
|
bool PcapPort::startStreamStatsTracking()
|
||||||
{
|
{
|
||||||
return rxStatsPoller_->start();
|
if (!transmitter_->setStreamStatsTracking(true))
|
||||||
|
goto _tx_fail;
|
||||||
|
if (!rxStatsPoller_->start())
|
||||||
|
goto _rx_fail;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
_rx_fail:
|
||||||
|
transmitter_->setStreamStatsTracking(false);
|
||||||
|
_tx_fail:
|
||||||
|
qWarning("failed to start stream stats tracking");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PcapPort::stopStreamStatsTracking()
|
bool PcapPort::stopStreamStatsTracking()
|
||||||
{
|
{
|
||||||
return rxStatsPoller_->stop();
|
if (!transmitter_->setStreamStatsTracking(false))
|
||||||
|
goto _tx_fail;
|
||||||
|
if (!rxStatsPoller_->stop())
|
||||||
|
goto _rx_fail;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
_rx_fail:
|
||||||
|
transmitter_->setStreamStatsTracking(true);
|
||||||
|
_tx_fail:
|
||||||
|
qWarning("failed to stop stream stats tracking");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PcapPort::startDeviceEmulation()
|
void PcapPort::startDeviceEmulation()
|
||||||
|
@ -43,6 +43,11 @@ bool PcapTransmitter::setRateAccuracy(
|
|||||||
return txThread_.setRateAccuracy(accuracy);
|
return txThread_.setRateAccuracy(accuracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PcapTransmitter::setStreamStatsTracking(bool enable)
|
||||||
|
{
|
||||||
|
return txThread_.setStreamStatsTracking(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void PcapTransmitter::clearPacketList()
|
void PcapTransmitter::clearPacketList()
|
||||||
{
|
{
|
||||||
txThread_.clearPacketList();
|
txThread_.clearPacketList();
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
~PcapTransmitter();
|
~PcapTransmitter();
|
||||||
|
|
||||||
bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
||||||
|
bool setStreamStatsTracking(bool enable);
|
||||||
|
|
||||||
void clearPacketList();
|
void clearPacketList();
|
||||||
void loopNextPacketSet(qint64 size, qint64 repeats,
|
void loopNextPacketSet(qint64 size, qint64 repeats,
|
||||||
|
@ -39,6 +39,7 @@ PcapTxThread::PcapTxThread(const char *device)
|
|||||||
#endif
|
#endif
|
||||||
state_ = kNotStarted;
|
state_ = kNotStarted;
|
||||||
stop_ = false;
|
stop_ = false;
|
||||||
|
trackStreamStats_ = false;
|
||||||
clearPacketList();
|
clearPacketList();
|
||||||
handle_ = pcap_open_live(device, 64 /* FIXME */, 0, 1000 /* ms */, errbuf);
|
handle_ = pcap_open_live(device, 64 /* FIXME */, 0, 1000 /* ms */, errbuf);
|
||||||
|
|
||||||
@ -82,6 +83,12 @@ bool PcapTxThread::setRateAccuracy(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PcapTxThread::setStreamStatsTracking(bool enable)
|
||||||
|
{
|
||||||
|
trackStreamStats_ = enable;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void PcapTxThread::clearPacketList()
|
void PcapTxThread::clearPacketList()
|
||||||
{
|
{
|
||||||
Q_ASSERT(!isRunning());
|
Q_ASSERT(!isRunning());
|
||||||
@ -103,7 +110,7 @@ void PcapTxThread::clearPacketList()
|
|||||||
void PcapTxThread::loopNextPacketSet(qint64 size, qint64 repeats,
|
void PcapTxThread::loopNextPacketSet(qint64 size, qint64 repeats,
|
||||||
long repeatDelaySec, long repeatDelayNsec)
|
long repeatDelaySec, long repeatDelayNsec)
|
||||||
{
|
{
|
||||||
currentPacketSequence_ = new PacketSequence;
|
currentPacketSequence_ = new PacketSequence(trackStreamStats_);
|
||||||
currentPacketSequence_->repeatCount_ = repeats;
|
currentPacketSequence_->repeatCount_ = repeats;
|
||||||
currentPacketSequence_->usecDelay_ = repeatDelaySec * long(1e6)
|
currentPacketSequence_->usecDelay_ = repeatDelaySec * long(1e6)
|
||||||
+ repeatDelayNsec/1000;
|
+ repeatDelayNsec/1000;
|
||||||
@ -141,7 +148,7 @@ bool PcapTxThread::appendToPacketList(long sec, long nsec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! \todo (LOW): calculate sendqueue size
|
//! \todo (LOW): calculate sendqueue size
|
||||||
currentPacketSequence_ = new PacketSequence;
|
currentPacketSequence_ = new PacketSequence(trackStreamStats_);
|
||||||
|
|
||||||
packetSequenceList_.append(currentPacketSequence_);
|
packetSequenceList_.append(currentPacketSequence_);
|
||||||
|
|
||||||
@ -342,7 +349,8 @@ _restart:
|
|||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
updateStreamStats();
|
if (trackStreamStats_)
|
||||||
|
updateStreamStats();
|
||||||
|
|
||||||
state_ = kFinished;
|
state_ = kFinished;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
~PcapTxThread();
|
~PcapTxThread();
|
||||||
|
|
||||||
bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
||||||
|
bool setStreamStatsTracking(bool enable);
|
||||||
|
|
||||||
void clearPacketList();
|
void clearPacketList();
|
||||||
void loopNextPacketSet(qint64 size, qint64 repeats,
|
void loopNextPacketSet(qint64 size, qint64 repeats,
|
||||||
@ -87,6 +88,7 @@ private:
|
|||||||
volatile bool stop_;
|
volatile bool stop_;
|
||||||
volatile State state_;
|
volatile State state_;
|
||||||
|
|
||||||
|
bool trackStreamStats_;
|
||||||
StatsTuple *stats_;
|
StatsTuple *stats_;
|
||||||
StatsTuple lastStats_;
|
StatsTuple lastStats_;
|
||||||
StreamStats streamStats_;
|
StreamStats streamStats_;
|
||||||
|
Loading…
Reference in New Issue
Block a user