|
From: <cn...@us...> - 2024-08-21 19:58:40
|
Revision: 1525
http://sourceforge.net/p/seq/svn/1525
Author: cn187
Date: 2024-08-21 19:58:37 +0000 (Wed, 21 Aug 2024)
Log Message:
-----------
Attempt to detect dropped packets and notify user
Modified Paths:
--------------
showeq/trunk/src/packetcapture.cpp
showeq/trunk/src/packetcapture.h
Modified: showeq/trunk/src/packetcapture.cpp
===================================================================
--- showeq/trunk/src/packetcapture.cpp 2024-08-21 19:58:30 UTC (rev 1524)
+++ showeq/trunk/src/packetcapture.cpp 2024-08-21 19:58:37 UTC (rev 1525)
@@ -35,7 +35,10 @@
#include "diagnosticmessages.h"
//#define PCAP_DEBUG 1
-
+
+unsigned int PacketCaptureThread::last_ps_ifdrop = 0;
+unsigned int PacketCaptureThread::last_ps_drop = 0;
+
//----------------------------------------------------------------------
// PacketCaptureThread
// start and stop the thread
@@ -45,8 +48,7 @@
m_playbackSpeed(0),
m_snaplen(snaplen),
m_buffersize(buffersize)
-{
-}
+{ }
PacketCaptureThread::~PacketCaptureThread()
{
@@ -55,7 +57,6 @@
// Turn off pcap
pcap_close(m_pcache_pcap);
}
-
}
void PacketCaptureThread::setPlaybackSpeed(int playbackSpeed)
@@ -335,6 +336,31 @@
}
pthread_mutex_unlock (&myThis->m_pcache_mutex);
+
+ struct pcap_stat ps = {0};
+
+ //NOTE: using fprintf here because seqWarn sends a MessageEntry, which
+ //can't cross thread boundaries using signals/slots without doing work
+ //to change MessageEntry to a proper Qt MetaType FIXME
+ pcap_stats(myThis->m_pcache_pcap, &ps);
+ if (ps.ps_ifdrop > 0 && ps.ps_ifdrop != last_ps_ifdrop)
+ {
+ fprintf(stderr, "PCAP detected %d packets dropped at the network interface! "
+ "This could cause ShowEQ to malfunction. Read FAQ #5 in the "
+ "FAQ located in the ShowEQ source directory for information "
+ "about tuning your kernel networking parameters.\n", ps.ps_ifdrop);
+ fprintf(stderr, "Packet loss due to dropping at the interface: %02f%%\n", (ps.ps_ifdrop * 1.0) / (ps.ps_recv * 1.0) * 100.0);
+ last_ps_ifdrop = ps.ps_ifdrop;
+ }
+
+ if (ps.ps_drop > 0 && ps.ps_drop != last_ps_drop)
+ {
+ fprintf(stderr, "PCAP detected %d packets dropped due to insufficent PCAP buffer size! "
+ "This could cause ShowEQ to malfunction. Increase the PCAP buffer "
+ "size and/or decrease the PCAP snapshot length.\n", ps.ps_drop);
+ fprintf(stderr, "Packet loss due to dropping at the PCAP buffer: %02f%%\n", (ps.ps_drop * 1.0) / (ps.ps_recv * 1.0) * 100.0);
+ last_ps_drop = ps.ps_drop;
+ }
}
void PacketCaptureThread::setFilter (const char *device,
Modified: showeq/trunk/src/packetcapture.h
===================================================================
--- showeq/trunk/src/packetcapture.h 2024-08-21 19:58:30 UTC (rev 1524)
+++ showeq/trunk/src/packetcapture.h 2024-08-21 19:58:37 UTC (rev 1525)
@@ -79,6 +79,8 @@
private:
static void* loop(void *param);
static void packetCallBack(u_char * param, const struct pcap_pkthdr *ph, const u_char *data);
+ static unsigned int last_ps_ifdrop;
+ static unsigned int last_ps_drop;
pcap_t *m_pcache_pcap;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|