mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.91k stars 375 forks source link

Unexpected packet timestamps from capture file #384

Open owk opened 4 years ago

owk commented 4 years ago

Hi,

First, thanks for the amazing work on this library, I was able to outperform my old C# tracing tool by 200%!

Secondly, I was wondering if you could give me some advice here. I started with this (Windows 10, VS2019):

sniffer.sniff_loop([&](Tins::Packet& packet) { this->process_packet(packet); return true; }); This worked for me, but when using FileSniffer, timestamps were not the ones from the file, but from the moment the file was read (and I really really need those timestamps...).

I saw in sniffer.h a check is present to prevent using invoke_loop_cb when you compile in VS (3478c7b09a746b5e3fbcbbf2e84e606a7291e2a5), which would force me to write a handler for PDU's instead of Packets (which I can't as I need the timestamps). I'm wondering if this could have something to do with it...?

I circumvented my original issue by making two changes:

Would there be a better way to implement this (maybe without my changes)? Any help is welcome!

Thanks