Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get timestamp with wrong value while reading from pcap file #480

Closed
nicholaswbsr opened this issue Jun 15, 2022 · 1 comment
Closed

get timestamp with wrong value while reading from pcap file #480

nicholaswbsr opened this issue Jun 15, 2022 · 1 comment

Comments

@nicholaswbsr
Copy link

Hi,

I want to get the timestamp from pcap file, thus I can know when the package is captured.
But the timestamp seconds always show up the current time.
For example I open pcap file via Wireshark then I can see the package captured with seconds: 1654494730 which represent around June 6, 2022 13:52.
But while I run the code I got 1655275668, represent my current local time: June 15, 2022.

Here is my code snap:

    FileSniffer sniffer("../inputs/example.pcap");
    int8_t counter = 0;
    PDU * some_pdu = sniffer.next_packet();
    Packet packet = *some_pdu;
    auto sec = packet.timestamp().seconds();
    std::cout << sec;

@nicholaswbsr
Copy link
Author

I fingered out the reason myself.

Change to the this then fixed.

    Packet some_pdu = sniffer.next_packet();
    auto sec = some_pdu.timestamp().seconds();
    std::cout << "next_packet: " << sec << std::endl;

It means only class Packet has the wrapper for timestamp not class PDU. So we must take Packet reference directly not construct from PDU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant