Skip to content

fix(ipv4): TS rebuild floors a float and loses 1 ms on ~1% of timestamps #1391

Closed

Description

@JarryShaw

Describe the bug
_make_opt_ts converts a timedelta to milliseconds with math.floor(ts.total_seconds() * 1000) (pcapkit/protocols/internet/ipv4.py:1603, :1612, :1635, :1652). The float product is inexact (1.001 × 1000 = 1000.9999999999999), so the floor loses 1 ms. The reader (schema/internet/ipv4.py:395) is exact, so parse → rebuild is not byte-exact.

To Reproduce

  • The from_data round trip of the TS option 44080900 000003e9 (flag 0, one stamp of 1001 ms) rebuilds as 44080900 000003e8.
  • 1001 ms is the smallest failing value. 23,602 of the first 3,000,000 values fail.
  • Flag 1 and make(timestamp=[timedelta(milliseconds=1001)]) fail the same way.
  • No other total_seconds() site in pcapkit/ has the problem.

Expected behavior
Every 31-bit stamp rebuilds unchanged. Integer arithmetic, td // timedelta(milliseconds=1), gives 1001.

Reproduced on main at 66950b1f2; found by the #1390 cross-review. Blocked until #1390 merges, because both edit _make_opt_ts.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 7, 2026
  2. moved this to Blocked in PyPCAPKiton Oct 7, 2026
  3. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1390 has merged. One worker is taking #1391, #1392 and #1393 together, because all three edit the IPv4 TS and SEC option code.

  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 8, 2026
  5. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions