Reoganize code using subrepo for Ostinato (part 2)
This commit includes all the new and modified files
This commit is contained in:
parent
5edf9a75e5
commit
843733567a
@ -26,6 +26,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include <qendian.h>
|
||||
|
||||
#if 0
|
||||
#ifdef qDebug
|
||||
#undef qDebug
|
||||
#define qDebug(...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class AbstractProtocol
|
||||
|
||||
|
@ -27,6 +27,7 @@ struct FrameValueAttrib
|
||||
enum ErrorFlag {
|
||||
UnresolvedSrcMacError = 0x1,
|
||||
UnresolvedDstMacError = 0x2,
|
||||
OutOfMemoryError = 0x4,
|
||||
};
|
||||
Q_DECLARE_FLAGS(ErrorFlags, ErrorFlag);
|
||||
ErrorFlags errorFlags{0};
|
||||
|
@ -1,3 +1,3 @@
|
||||
QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS] -std=c++11
|
||||
CONFIG(debug, debug|release): QMAKE_CXXFLAGS_WARN_ON += -Wall -W -Wextra -Werror
|
||||
CONFIG(debug, debug|release): QMAKE_CXXFLAGS_WARN_ON += -Wall -W -Wextra -Werror -Wno-error
|
||||
CONFIG(debug, debug|release): QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-declarations
|
||||
|
@ -33,6 +33,8 @@ RpcServer::RpcServer(bool perConnLogs)
|
||||
|
||||
RpcServer::~RpcServer()
|
||||
{
|
||||
close();
|
||||
emit closed();
|
||||
}
|
||||
|
||||
bool RpcServer::registerService(::google::protobuf::Service *service,
|
||||
@ -73,6 +75,7 @@ void RpcServer::incomingConnection(qintptr socketDescriptor)
|
||||
|
||||
connect(this, SIGNAL(notifyClients(int, SharedProtobufMessage)),
|
||||
conn, SLOT(sendNotification(int, SharedProtobufMessage)));
|
||||
connect(this, SIGNAL(closed()), thread, SLOT(quit()));
|
||||
|
||||
thread->start();
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
QHostAddress address, quint16 tcpPortNum);
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
void notifyClients(int notifType, SharedProtobufMessage notifData);
|
||||
|
||||
protected:
|
||||
|
@ -315,8 +315,10 @@ int AbstractPort::updatePacketListSequential()
|
||||
qDebug("npx2 = %llu", npx2);
|
||||
qDebug("npy2 = %llu\n", npy2);
|
||||
|
||||
if (n > 1)
|
||||
if (n >= 1) {
|
||||
loopNextPacketSet(x, n, 0, loopDelay);
|
||||
qDebug("PacketSet: n = %lu, x = %lu", n, x);
|
||||
}
|
||||
else if (n == 0)
|
||||
x = 0;
|
||||
|
||||
@ -333,10 +335,20 @@ int AbstractPort::updatePacketListSequential()
|
||||
if (len <= 0)
|
||||
continue;
|
||||
|
||||
// Create a packet set for 'y' with repeat = 1
|
||||
if (j == x) {
|
||||
loopNextPacketSet(y, 1, 0, loopDelay);
|
||||
qDebug("PacketSet: n = 1, y = %lu", y);
|
||||
}
|
||||
|
||||
qDebug("q(%d, %d) sec = %lu nsec = %lu",
|
||||
i, j, sec, nsec);
|
||||
|
||||
appendToPacketList(sec, nsec, pktBuf_, len);
|
||||
if (!appendToPacketList(sec, nsec, pktBuf_, len)) {
|
||||
clearPacketList(); // don't leave it half baked/inconsitent
|
||||
packetListAttrib.errorFlags |= FrameValueAttrib::OutOfMemoryError;
|
||||
goto _out_of_memory;
|
||||
}
|
||||
|
||||
if ((j > 0) && (((j+1) % burstSize) == 0))
|
||||
{
|
||||
@ -397,6 +409,7 @@ int AbstractPort::updatePacketListSequential()
|
||||
} // if (stream is enabled)
|
||||
} // for (numStreams)
|
||||
|
||||
_out_of_memory:
|
||||
_stop_no_more_pkts:
|
||||
isSendQueueDirty_ = false;
|
||||
|
||||
@ -410,7 +423,7 @@ int AbstractPort::updatePacketListInterleaved()
|
||||
FrameValueAttrib packetListAttrib;
|
||||
int numStreams = 0;
|
||||
quint64 minGap = ULLONG_MAX;
|
||||
quint64 duration = quint64(1e9);
|
||||
quint64 duration = quint64(1e3);
|
||||
QList<quint64> ibg1, ibg2;
|
||||
QList<quint64> nb1, nb2;
|
||||
QList<quint64> ipg1, ipg2;
|
||||
@ -568,6 +581,11 @@ int AbstractPort::updatePacketListInterleaved()
|
||||
qDebug("minGap = %llu", minGap);
|
||||
qDebug("duration = %llu", duration);
|
||||
|
||||
if (duration < minGap*100) {
|
||||
duration = minGap*100;
|
||||
qDebug("increase duration to %llu for better accuracy", duration);
|
||||
}
|
||||
|
||||
uchar* buf;
|
||||
int len;
|
||||
quint64 durSec = duration/ulong(1e9);
|
||||
@ -604,7 +622,11 @@ int AbstractPort::updatePacketListInterleaved()
|
||||
continue;
|
||||
|
||||
qDebug("q(%d) sec = %llu nsec = %llu", i, sec, nsec);
|
||||
appendToPacketList(sec, nsec, buf, len);
|
||||
if (!appendToPacketList(sec, nsec, buf, len)) {
|
||||
clearPacketList(); // don't leave it half baked/inconsitent
|
||||
packetListAttrib.errorFlags |= FrameValueAttrib::OutOfMemoryError;
|
||||
goto _out_of_memory;
|
||||
}
|
||||
lastPktTxSec = sec;
|
||||
lastPktTxNsec = nsec;
|
||||
|
||||
@ -636,15 +658,19 @@ int AbstractPort::updatePacketListInterleaved()
|
||||
}
|
||||
} while ((sec < durSec) || (nsec < durNsec));
|
||||
|
||||
qint64 delaySec = durSec - lastPktTxSec;
|
||||
qint64 delayNsec = durNsec - lastPktTxNsec;
|
||||
while (delayNsec < 0)
|
||||
{
|
||||
delayNsec += long(1e9);
|
||||
delaySec--;
|
||||
qint64 delaySec = durSec - lastPktTxSec;
|
||||
qint64 delayNsec = durNsec - lastPktTxNsec;
|
||||
while (delayNsec < 0)
|
||||
{
|
||||
delayNsec += long(1e9);
|
||||
delaySec--;
|
||||
}
|
||||
qDebug("loop Delay = %lld/%lld", delaySec, delayNsec);
|
||||
setPacketListLoopMode(true, delaySec, delayNsec);
|
||||
}
|
||||
qDebug("loop Delay = %lld/%lld", delaySec, delayNsec);
|
||||
setPacketListLoopMode(true, delaySec, delayNsec);
|
||||
|
||||
_out_of_memory:
|
||||
isSendQueueDirty_ = false;
|
||||
|
||||
qDebug("PacketListAttrib = %x",
|
||||
@ -688,6 +714,9 @@ void AbstractPort::stats(PortStats *stats)
|
||||
|
||||
void AbstractPort::streamStats(uint guid, OstProto::StreamStatsList *stats)
|
||||
{
|
||||
// In case stats are being maintained elsewhere
|
||||
updateStreamStats();
|
||||
|
||||
if (streamStats_.contains(guid))
|
||||
{
|
||||
StreamStatsTuple sst = streamStats_.value(guid);
|
||||
@ -705,6 +734,9 @@ void AbstractPort::streamStats(uint guid, OstProto::StreamStatsList *stats)
|
||||
|
||||
void AbstractPort::streamStatsAll(OstProto::StreamStatsList *stats)
|
||||
{
|
||||
// In case stats are being maintained elsewhere
|
||||
updateStreamStats();
|
||||
|
||||
// FIXME: change input param to a non-OstProto type and/or have
|
||||
// a getFirst/Next like API?
|
||||
StreamStatsIterator i(streamStats_);
|
||||
|
@ -124,6 +124,9 @@ public:
|
||||
void streamStatsAll(OstProto::StreamStatsList *stats);
|
||||
void resetStreamStats(uint guid);
|
||||
void resetStreamStatsAll();
|
||||
virtual void updateStreamStats() {
|
||||
// subclasses may implement - if required
|
||||
}
|
||||
|
||||
DeviceManager* deviceManager();
|
||||
virtual void startDeviceEmulation() = 0;
|
||||
|
@ -1,5 +1,6 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += qt ver_info c++11
|
||||
addon: CONFIG -= ver_info
|
||||
QT += network script xml
|
||||
QT -= gui
|
||||
linux*:system(grep -q IFLA_STATS64 /usr/include/linux/if_link.h): \
|
||||
|
@ -30,7 +30,7 @@ class LinuxPort : public PcapPort
|
||||
{
|
||||
public:
|
||||
LinuxPort(int id, const char *device);
|
||||
~LinuxPort();
|
||||
virtual ~LinuxPort();
|
||||
|
||||
void init();
|
||||
|
||||
|
@ -1249,6 +1249,9 @@ QString MyService::frameValueErrorNotes(int portId, int error)
|
||||
QString pfx = QString("Port %1: ").arg(portId);
|
||||
auto errorFlags = static_cast<FrameValueAttrib::ErrorFlags>(error);
|
||||
|
||||
if (errorFlags & FrameValueAttrib::OutOfMemoryError)
|
||||
return pfx + "Error building packet buffers - out of buffer memory\n";
|
||||
|
||||
// If smac resolve fails, dmac will always fail - so check that first
|
||||
// and report only that so as not to confuse users (they may not realize
|
||||
// that without a source device, we have no ARP table to lookup for dmac)
|
||||
|
@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#include "pcaptransmitter.h"
|
||||
#include "pcaptxthread.h"
|
||||
|
||||
#include "statstuple.h"
|
||||
#include "timestamp.h"
|
||||
@ -109,6 +109,11 @@ void PcapTxThread::clearPacketList()
|
||||
void PcapTxThread::loopNextPacketSet(qint64 size, qint64 repeats,
|
||||
long repeatDelaySec, long repeatDelayNsec)
|
||||
{
|
||||
// Since we create implicit packetset for this case, skip
|
||||
// This case => Packet set for y when x = 0 or n==1 in n*x+y
|
||||
if (repeats == 1)
|
||||
return;
|
||||
|
||||
currentPacketSequence_ = new PacketSequence(trackStreamStats_);
|
||||
currentPacketSequence_->repeatCount_ = repeats;
|
||||
currentPacketSequence_->usecDelay_ = repeatDelaySec * long(1e6)
|
||||
|
@ -17,6 +17,10 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifdef TURBO
|
||||
#include "xdpport.h" // MUST be included first - see why in xdpport.h
|
||||
#endif
|
||||
|
||||
#include "portmanager.h"
|
||||
|
||||
#include "bsdport.h"
|
||||
@ -93,7 +97,11 @@ PortManager::PortManager()
|
||||
#if defined(Q_OS_WIN32)
|
||||
port = new WinPcapPort(i, device->name, device->description);
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#ifdef TURBO
|
||||
port = new XdpPort(i, device->name);
|
||||
#else
|
||||
port = new LinuxPort(i, device->name);
|
||||
#endif
|
||||
#elif defined(Q_OS_BSD4)
|
||||
port = new BsdPort(i, device->name);
|
||||
#else
|
||||
|
@ -20,9 +20,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#ifndef _TIMESTAMP_H
|
||||
#define _TIMESTAMP_H
|
||||
|
||||
#include "timespecops.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <sys/time.h>
|
||||
#ifdef USE_NSEC_TIMESTAMP
|
||||
typedef struct timespec TimeStamp;
|
||||
static void inline getTimeStamp(TimeStamp *stamp)
|
||||
{
|
||||
clock_gettime(CLOCK_MONOTONIC, stamp);
|
||||
}
|
||||
|
||||
// Returns time diff in nsecs between end and start
|
||||
static long inline ndiffTimeStamp(const TimeStamp *start, const TimeStamp *end)
|
||||
{
|
||||
struct timespec diff;
|
||||
timespecsub(end, start, &diff);
|
||||
|
||||
long nsecs = diff.tv_nsec;
|
||||
if (diff.tv_sec)
|
||||
nsecs += diff.tv_sec*1e9;
|
||||
|
||||
return nsecs;
|
||||
}
|
||||
#else
|
||||
typedef struct timeval TimeStamp;
|
||||
static void inline getTimeStamp(TimeStamp *stamp)
|
||||
{
|
||||
@ -43,6 +66,8 @@ static long inline udiffTimeStamp(const TimeStamp *start, const TimeStamp *end)
|
||||
|
||||
return usecs;
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(Q_OS_WIN32)
|
||||
static quint64 gTicksFreq;
|
||||
typedef LARGE_INTEGER TimeStamp;
|
||||
|
Loading…
Reference in New Issue
Block a user