|
From: <cn...@us...> - 2024-08-21 19:58:33
|
Revision: 1524
http://sourceforge.net/p/seq/svn/1524
Author: cn187
Date: 2024-08-21 19:58:30 +0000 (Wed, 21 Aug 2024)
Log Message:
-----------
Allow user to configure PCAP snaplen and ring buffer size
Modified Paths:
--------------
showeq/trunk/src/interface.cpp
showeq/trunk/src/interface.h
showeq/trunk/src/packet.cpp
showeq/trunk/src/packet.h
showeq/trunk/src/packetcapture.cpp
showeq/trunk/src/packetcapture.h
Modified: showeq/trunk/src/interface.cpp
===================================================================
--- showeq/trunk/src/interface.cpp 2024-08-21 19:58:23 UTC (rev 1523)
+++ showeq/trunk/src/interface.cpp 2024-08-21 19:58:30 UTC (rev 1524)
@@ -235,7 +235,7 @@
if (!selected.isEmpty())
{
// set it as the device to monitor next session
- pSEQPrefs->setPrefString("Device", "Network", selected);
+ pSEQPrefs->setPrefString("Device", section, selected);
net_device = selected;
}
}
@@ -249,6 +249,8 @@
pSEQPrefs->getPrefString("MAC", section, "0"),
pSEQPrefs->getPrefBool("RealTimeThread", section,
false),
+ pSEQPrefs->getPrefInt("CaptureSnapLen", section, 1),
+ pSEQPrefs->getPrefInt("CaptureBufferSize", section, 2),
pSEQPrefs->getPrefBool("SessionTracking",
section, false),
pSEQPrefs->getPrefBool("Record", vpsection, false),
@@ -1186,6 +1188,41 @@
tmpAction->setCheckable(true);
tmpAction->setChecked(m_packet->realtime());
+ QMenu* captureMenu = new QMenu("Packet Capture Configuration");
+ m_netMenu->addMenu(captureMenu);
+
+
+ QWidgetAction* captureSettingNotice = new QWidgetAction(captureMenu);
+ QLabel* tmpLabel = new QLabel("NOTE: You must save preferences and restart ShowEQ for these changes to take effect (for now)");
+ tmpLabel->setWordWrap(true);
+ tmpLabel->setContentsMargins(30, 11, 11, 11);
+ captureSettingNotice->setDefaultWidget(tmpLabel);
+ captureMenu->addAction(captureSettingNotice);
+
+ captureMenu->addSeparator();
+
+ QMenu* tmpMenu = new QMenu("Snapshot Length (KB)");
+ QSpinBox* snapLenSpinBox = new QSpinBox(tmpMenu);
+ snapLenSpinBox->setMinimum(1);
+ snapLenSpinBox->setMaximum(64);
+ snapLenSpinBox->setValue(pSEQPrefs->getPrefInt("CaptureSnapLen", "Network", 1));
+ connect(snapLenSpinBox, SIGNAL(valueChanged(int)), this, SLOT(set_net_capture_snap_len(int)));
+ QWidgetAction* snapLenWidgetAction = new QWidgetAction(tmpMenu);
+ snapLenWidgetAction->setDefaultWidget(snapLenSpinBox);
+ tmpMenu->addAction(snapLenWidgetAction);
+ captureMenu->addMenu(tmpMenu);
+
+ tmpMenu = new QMenu("Capture Buffer Size (MB)");
+ QSpinBox* captureBufferSizeSpinBox = new QSpinBox();
+ captureBufferSizeSpinBox->setMinimum(2);
+ captureBufferSizeSpinBox->setMaximum(128);
+ captureBufferSizeSpinBox->setValue(pSEQPrefs->getPrefInt("CaptureBufferSize", "Network", 2));
+ connect(captureBufferSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(set_net_capture_buffer_size(int)));
+ QWidgetAction* captureBufferSizeWidgetAction = new QWidgetAction(tmpMenu);
+ captureBufferSizeWidgetAction->setDefaultWidget(captureBufferSizeSpinBox);
+ tmpMenu->addAction(captureBufferSizeWidgetAction);
+ captureMenu->addMenu(tmpMenu);
+
m_netMenu->addSeparator();
// Log menu
@@ -5316,6 +5353,18 @@
}
}
+void EQInterface::set_net_capture_snap_len(int len)
+{
+ m_packet->setSnapLen(len);
+ pSEQPrefs->setPrefInt("CaptureSnapLen", "Network", len);
+}
+
+void EQInterface::set_net_capture_buffer_size(int size)
+{
+ m_packet->setBufferSize(size);
+ pSEQPrefs->setPrefInt("CaptureBufferSize", "Network", size);
+}
+
void EQInterface::set_net_arq_giveup(int giveup)
{
// set the Arq Seq Give Up length
Modified: showeq/trunk/src/interface.h
===================================================================
--- showeq/trunk/src/interface.h 2024-08-21 19:58:23 UTC (rev 1523)
+++ showeq/trunk/src/interface.h 2024-08-21 19:58:30 UTC (rev 1524)
@@ -224,6 +224,8 @@
void set_net_client_IP_address();
void set_net_client_MAC_address();
void set_net_device();
+ void set_net_capture_snap_len(int len);
+ void set_net_capture_buffer_size(int size);
void set_net_arq_giveup(int giveup);
virtual void setCaption(const QString&);
void restoreStatusFont();
Modified: showeq/trunk/src/packet.cpp
===================================================================
--- showeq/trunk/src/packet.cpp 2024-08-21 19:58:23 UTC (rev 1523)
+++ showeq/trunk/src/packet.cpp 2024-08-21 19:58:30 UTC (rev 1524)
@@ -92,6 +92,8 @@
QString ip,
QString mac_address,
bool realtime,
+ int snaplen,
+ int buffersize,
bool sessionTrackingFlag,
bool recordPackets,
int playbackPackets,
@@ -107,6 +109,8 @@
m_ip(ip),
m_mac(mac_address),
m_realtime(realtime),
+ m_snaplen(snaplen),
+ m_buffersize(buffersize),
m_session_tracking(sessionTrackingFlag),
m_recordPackets(recordPackets),
m_playbackPackets(playbackPackets),
@@ -193,7 +197,7 @@
if (m_playbackPackets == PLAYBACK_OFF)
{
// create the pcap object and initialize, either with MAC or IP
- m_packetCapture = new PacketCaptureThread();
+ m_packetCapture = new PacketCaptureThread(m_snaplen, m_buffersize);
if (m_mac.length() == 17)
{
seqInfo("Listening for client MAC: %s", m_mac.toLatin1().data());
@@ -218,7 +222,7 @@
else if (m_playbackPackets == PLAYBACK_FORMAT_TCPDUMP)
{
// Create the pcap object and initialize with the file input given
- m_packetCapture = new PacketCaptureThread();
+ m_packetCapture = new PacketCaptureThread(m_snaplen, m_buffersize);
QString filename = pSEQPrefs->getPrefString("Filename", "VPacket");
Modified: showeq/trunk/src/packet.h
===================================================================
--- showeq/trunk/src/packet.h 2024-08-21 19:58:23 UTC (rev 1523)
+++ showeq/trunk/src/packet.h 2024-08-21 19:58:30 UTC (rev 1524)
@@ -72,6 +72,8 @@
QString m_ip,
QString m_mac_address,
bool m_realtime,
+ int snaplen,
+ int buffersize,
bool m_session_tracking,
bool m_recordPackets,
int m_playbackPackets,
@@ -102,6 +104,10 @@
bool connect2(const QString& opcodeName, EQStreamPairs sp,
uint8_t dir, const char* payload, EQSizeCheckType szt,
const QObject* receiver, const char* member);
+ int snaplen(void) { return m_snaplen; }
+ int buffersize(void) { return m_buffersize; }
+ void setSnapLen(int len) { m_snaplen = len; }
+ void setBufferSize(int size) { m_buffersize = size; }
public slots:
void processPackets(void);
@@ -176,6 +182,8 @@
QString m_ip;
QString m_mac;
bool m_realtime;
+ int m_snaplen;
+ int m_buffersize;
bool m_session_tracking;
bool m_recordPackets;
int m_playbackPackets;
Modified: showeq/trunk/src/packetcapture.cpp
===================================================================
--- showeq/trunk/src/packetcapture.cpp 2024-08-21 19:58:23 UTC (rev 1523)
+++ showeq/trunk/src/packetcapture.cpp 2024-08-21 19:58:30 UTC (rev 1524)
@@ -40,9 +40,11 @@
// PacketCaptureThread
// start and stop the thread
// get packets to the processing engine(dispatchPacket)
-PacketCaptureThread::PacketCaptureThread() : PacketCaptureProviderThread(),
+PacketCaptureThread::PacketCaptureThread(int snaplen, int buffersize) : PacketCaptureProviderThread(),
m_pcache_pcap(NULL),
- m_playbackSpeed(0)
+ m_playbackSpeed(0),
+ m_snaplen(snaplen),
+ m_buffersize(buffersize)
{
}
@@ -81,7 +83,6 @@
bool realtime, uint8_t address_type)
{
char ebuf[PCAP_ERRBUF_SIZE]; // pcap error buffer
- char filter_buf[256]; // pcap filter buffer
seqInfo("Initializing Packet Capture Thread: ");
m_pcache_closed = false;
@@ -109,11 +110,8 @@
}
pcap_set_promisc(m_pcache_pcap, 1);
- //PCAP docs say 64K snaplen should be enough for most networks.
- pcap_set_snaplen(m_pcache_pcap, UINT16_MAX);
- // default buffer size is 2M: 2*1024*1024
- // but we can increase it in the future if needed
- //pcap_set_buffer_size(m_pcache_pcap, 4*1024*1024);
+ pcap_set_snaplen(m_pcache_pcap, m_snaplen*1024);
+ pcap_set_buffer_size(m_pcache_pcap, m_buffersize*1024*1024);
#ifndef __FreeBSD__
pcap_set_immediate_mode(m_pcache_pcap, 1);
Modified: showeq/trunk/src/packetcapture.h
===================================================================
--- showeq/trunk/src/packetcapture.h 2024-08-21 19:58:23 UTC (rev 1523)
+++ showeq/trunk/src/packetcapture.h 2024-08-21 19:58:30 UTC (rev 1524)
@@ -54,7 +54,7 @@
class PacketCaptureThread : public PacketCaptureProviderThread
{
public:
- PacketCaptureThread();
+ PacketCaptureThread(int snaplen, int buffersize);
~PacketCaptureThread();
bool offlinePlaybackSupported() { return true; }
@@ -88,6 +88,9 @@
int m_playbackSpeed; // -1=paused, 0=max, 1=1x speed, 2=2x speed, up to 9
timeval m_tvLastProcessedActual;
timeval m_tvLastProcessedOriginal;
+
+ int m_snaplen;
+ int m_buffersize;
};
#endif // _PACKETCAPTURE_H_
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|