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

Fix precision issue on pcapng reader #1514

Merged
merged 2 commits into from
Aug 12, 2024
Merged

Conversation

mserdarsanli
Copy link
Contributor

Added test shows the problem of lost precision caused by using doubles to convert 64-bit timestamps to tv_sec and tv_nsec values. Next commit is the fix making code use integer arithmetic and timestamps now load correctly.

@mserdarsanli mserdarsanli requested a review from seladb as a code owner July 28, 2024 20:30
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We add a // PCPP patch comment everywhere we change something in LightPcapNg so we can later hopefully contribute them to the original repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amended the commit

@seladb
Copy link
Owner

seladb commented Aug 7, 2024

@mserdarsanli can you run clang-format on FileTests.cpp? pre-commit fails because of this:
https://github.com/seladb/PcapPlusPlus/actions/runs/10262682424/job/28392869466?pr=1514

If you don't know how to run it please let me know and I can run it for you

The library persists timespec values correctly in the pcapng files, as it
always uses nanosecond precision. But when reading pcapng file, to handle
arbitrary precision, it uses floating point arithmetic and loses precision
causing loaded tv_nsec values to be off up to 128 nanoseconds for
timestamps around now.
@mserdarsanli
Copy link
Contributor Author

Fixed the clang-format issue for that file

@seladb seladb merged commit 39913f1 into seladb:dev Aug 12, 2024
38 checks passed
@seladb
Copy link
Owner

seladb commented Aug 12, 2024

Thank you @mserdarsanli for working on this fix, much appreciated! 🙏 🙏

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

Successfully merging this pull request may close these issues.

2 participants