Hello,
the delay (-d) option is not satisfactory with low delays. The
unavoidable imprecision of the sleep time screws the actual pps a lot
(see
http://www.martani.net/2011/07/nanosleep-usleep-and-sleep-precision.html).
I believe also that nanosleep would just sweep the problem under the carpet.
A proper fix would be to check what time it is after resuming from
sleep, and then send packets according to time elapsed. Or one can
implement busy waiting for low usleep times, which is my current dirty hack:
diff --git a/staging/mz.h b/staging/mz.h
index cad091f..b77f6db 100644
--- a/staging/mz.h
+++ b/staging/mz.h
@@ -82,7 +82,20 @@ static inline void verbose_l2(const char *format,
...)
#define MZ_DEFAULT_CONFIG_PATH "/etc/mausezahn/" // see also
mz_default_config_path below
#define MZ_DEFAULT_LOG_PATH "/var/log/mausezahn/" // see also
mz_default_log_path below
-#define SLEEP usleep // The sleep function to use.
Consider 'nanosleep' in future.
+static inline void mz_sleep(unsigned long long delay)
+{
+ struct timespec t;
+ if (delay > 1000 || clock_gettime(CLOCK_MONOTONIC, &t))
usleep(delay);
+ else
+ {
+#define tmicro (t.tv_nsec / 1000 + t.tv_sec * 1000000ULL)
+ unsigned long long end = tmicro + delay;
+ while (clock_gettime(CLOCK_MONOTONIC, &t), tmicro < end)
sched_yield();
+#undef tmicro
+ }
+}
+
+#define SLEEP mz_sleep // The sleep function to use.
Consider 'nanosleep' in future.
#define DEFAULT_DELAY 0
#define PCAP_READ_TIMEOUT_MSEC 1 // The read timeout for
pcap_open_live()
#define MZ_MAX_DEVICES 10 // Max number of network
devices supported
--
You received this message because you are subscribed to the Google Groups
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.