You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ipv4): TS rebuild floors a float and loses 1 ms on ~1% of timestamps #1391
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.
Activity
JarryShaw commentedon Oct 8, 2026
Unblocked: #1390 has merged. One worker is taking #1391, #1392 and #1393 together, because all three edit the IPv4 TS and SEC option code.