From 8d85fd30defa458c42cdf70ded6c130eb9804fc5 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Mon, 17 Jan 2011 18:38:45 +0530 Subject: [PATCH] Jumbo frames support added. Max packet size currently is set to 16K - underlying OS and hardware needs to support jumbo frames to be able to actually use this feature. Fixes issue 27 --- client/portgroup.cpp | 2 +- client/streamconfigdialog.cpp | 5 +++-- client/streamconfigdialog.h | 4 ++-- client/streamconfigdialog.ui | 27 --------------------------- common/streambase.cpp | 14 ++++++++++---- server/abstractport.cpp | 9 ++++----- server/abstractport.h | 4 ++++ server/pcapport.cpp | 2 ++ 8 files changed, 26 insertions(+), 41 deletions(-) diff --git a/client/portgroup.cpp b/client/portgroup.cpp index 92bc097..63bc968 100644 --- a/client/portgroup.cpp +++ b/client/portgroup.cpp @@ -162,7 +162,7 @@ void PortGroup::when_portListChanged(quint32 /*portGroupId*/) { if (state() == QAbstractSocket::ConnectedState && numPorts() <= 0) { - QMessageBox::warning(NULL, tr("Ostinato"), + QMessageBox::warning(NULL, tr("No ports in portgroup"), QString("The portgroup %1:%2 does not contain any ports!\n\n" "Packet Transmit/Capture requires elevated privileges. " "Please ensure that you are running 'drone' - the server " diff --git a/client/streamconfigdialog.cpp b/client/streamconfigdialog.cpp index 94b5ded..981fabc 100644 --- a/client/streamconfigdialog.cpp +++ b/client/streamconfigdialog.cpp @@ -257,8 +257,9 @@ void StreamConfigDialog::setupUiExtra() ** Setup Validators */ // Meta Data - //! \todo - doesn't seem to work - range validator needs a spinbox? - //lePktLen->setValidator(new QIntValidator(MIN_PKT_LEN, MAX_PKT_LEN, this)); + lePktLen->setValidator(new QIntValidator(MIN_PKT_LEN, MAX_PKT_LEN, this)); + lePktLenMin->setValidator(new QIntValidator(MIN_PKT_LEN, MAX_PKT_LEN,this)); + lePktLenMax->setValidator(new QIntValidator(MIN_PKT_LEN, MAX_PKT_LEN,this)); /* ** Setup Connections diff --git a/client/streamconfigdialog.h b/client/streamconfigdialog.h index 5709570..bb91ce7 100644 --- a/client/streamconfigdialog.h +++ b/client/streamconfigdialog.h @@ -27,9 +27,9 @@ along with this program. If not, see #include "packetmodel.h" #include "modeltest.h" -#define MAX_MAC_ITER_COUNT 256 +#define MAX_MAC_ITER_COUNT 256 #define MIN_PKT_LEN 64 -#define MAX_PKT_LEN 1522 +#define MAX_PKT_LEN 16384 /* ** TODO diff --git a/client/streamconfigdialog.ui b/client/streamconfigdialog.ui index 6ec20a3..1f580a3 100644 --- a/client/streamconfigdialog.ui +++ b/client/streamconfigdialog.ui @@ -104,15 +104,6 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff false - - 0099; - - - - - - 4 - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -120,15 +111,6 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff - - - - - - - - 32767 - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -146,15 +128,6 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff false - - 0099; - - - - - - 4 - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/common/streambase.cpp b/common/streambase.cpp index f766fd7..53addbe 100644 --- a/common/streambase.cpp +++ b/common/streambase.cpp @@ -453,6 +453,7 @@ int StreamBase::frameValue(uchar *buf, int bufMaxSize, int frameIndex) const bool StreamBase::preflightCheck(QString &result) const { + bool pass = true; int count = isFrameSizeVariable() ? frameCount() : 1; for (int i = 0; i < count; i++) @@ -462,13 +463,18 @@ bool StreamBase::preflightCheck(QString &result) const result += QString("One or more frames may be truncated - " "frame length should be at least %1.\n") .arg(frameProtocolLength(i) + kFcsSize); - goto _fail; + pass = false; + } + + if (frameLen(i) > 1522) + { + result += QString("Jumbo frames may be truncated or dropped " + "if not supported by the hardware\n"); + pass = false; } } - return true; -_fail: - return false; + return pass; } bool StreamBase::StreamLessThan(StreamBase* stream1, StreamBase* stream2) diff --git a/server/abstractport.cpp b/server/abstractport.cpp index 5a08911..d0e8c0c 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -113,7 +113,6 @@ void AbstractPort::updatePacketList() { int len; bool isVariable; - uchar pktBuf[2000]; long sec = 0; long usec = 0; @@ -162,7 +161,7 @@ void AbstractPort::updatePacketList() else { isVariable = false; - len = streamList_[i]->frameValue(pktBuf, sizeof(pktBuf), 0); + len = streamList_[i]->frameValue(pktBuf_, sizeof(pktBuf_), 0); } for (int j = 0; j < numBursts; j++) @@ -171,8 +170,8 @@ void AbstractPort::updatePacketList() { if (isVariable) { - len = streamList_[i]->frameValue(pktBuf, - sizeof(pktBuf), j * numPackets + k); + len = streamList_[i]->frameValue(pktBuf_, + sizeof(pktBuf_), j * numPackets + k); } if (len <= 0) continue; @@ -180,7 +179,7 @@ void AbstractPort::updatePacketList() qDebug("q(%d, %d, %d) sec = %lu usec = %lu", i, j, k, sec, usec); - appendToPacketList(sec, usec, pktBuf, len); + appendToPacketList(sec, usec, pktBuf_, len); usec += ipg; if (usec > 1000000) diff --git a/server/abstractport.h b/server/abstractport.h index 4b036fa..e903007 100644 --- a/server/abstractport.h +++ b/server/abstractport.h @@ -94,6 +94,10 @@ protected: private: bool isSendQueueDirty_; + + static const int kMaxPktSize = 16384; + uchar pktBuf_[kMaxPktSize]; + /*! \note StreamBase::id() and index into streamList[] are NOT same! */ QList streamList_; diff --git a/server/pcapport.cpp b/server/pcapport.cpp index 222dd42..d4d1223 100644 --- a/server/pcapport.cpp +++ b/server/pcapport.cpp @@ -315,6 +315,8 @@ void PcapPort::PortTransmitter::run() int i; qDebug("sendQueueList_.size = %d", sendQueueList_.size()); + if (sendQueueList_.size() <= 0) + return; for(i = 0; i < sendQueueList_.size(); i++) {