Repository navigation
fix(mh): Message ID option always writes and reads a zero fraction - #1110
Merged
Merged
Conversation
The NTP fraction field is a 32-bit binary fraction of a second. `_make_opt_mesg_id` scaled it to microseconds and then multiplied by 2**32, so the packed field was always 0. It now writes round(frac * 2**32), clamped to 0xFFFFFFFF. `MesgIDOption.post_process` floored `fraction / 2**32` to 0 and now adds it as seconds, so `timestamp` keeps sub-second precision. Closes #1093
Owner
Author
|
Cross-review verdict on
Nit, pre-existing: the |
Contributor
|
Coverage: 84.75% (unit tier, Python 3.14,
Per-file detail: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort): ran with the Makefile flags on the two touched source files only; no new findingsmake testpasses, and a test case covers the change: ran the modules listed below, not the full suiteAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A, added centrally after the waveWhat is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseDescription of your pull request and other information
Closes #1093
_make_opt_mesg_idnow writesmin(round(frac * 2**32), 0xFFFFFFFF).MesgIDOption.post_processnow addsfraction / 2**32seconds.timestampis still a UTCdatetime, and it now has sub-second precision. The unusedmathimport is dropped from the schema module.Probe at
1_700_000_000.5, before → after: fraction2147483648000000→2147483648, bytes0a08e8fe6f8000000000→0a08e8fe6f8080000000, read22:13:20→22:13:20.500000.Tests (new
tests/protocols/internet/test_mh_mesg_id_fraction_unit.py): fractions 0, 0.5, 0.999999, an exact second, the clamp and the read scale.4 passed, 3 subtests passed. Fix reverted:4 failed, 2 passed(fraction 0 and the exact second pass either way).test_mh_unit.py52 passed,test_option_roundtrip_unit.py6 passed,tests/project379 passed, 1 skipped.