#include <iostream>
#include <tins/tins.h>
using namespace Tins;
using namespace std;
bool callback(const Packet& packet) {
const PDU* pdu = packet.pdu();
auto time = packet.timestamp().microseconds();
cout << time << endl;
//number should increasing??.
return true;
}
int main(int argc, char *argv[])
{
if(argc < 2) {
fprintf(stderr, "Usage: %s input.pcap\n", argv[0]);
return -1;
}
SnifferConfiguration config;
config.set_filter("tcp or udp");
config.set_promisc_mode(false);
FileSniffer sniffer(argv[1], config);
sniffer.sniff_loop(callback);
return 0;
}
Well, i used libtins to parse the pcap file, in order to get the packet timestamp, and the result is weird!
I use wireshark to check the pcap file, the duration is 28s, but the libtins show a wrong timestamp of each packet. it would overflow after the number bigger than 999999....why?
I compile the library from github, but still got the wrong answer, please