Skip to content

fix(tcp): keep Quick-Start rate an int and a Fast Open cookie request bytes (#2167) - #2185

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2167-tcp-qs-fastopen-types
Oct 25, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2167-tcp-qs-fastopen-types

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Description

Closes #2167.

  • Quick-Start rate: the readers in TCP._read_mode_qs, IPv4._read_opt_qs, HOPOPT._read_opt_qs and IPv6_Opts._read_opt_qs used true division, so 80 kbps parsed as 80.0 against an int annotation. They now use //, which is exact because the rate is always 40·2^N kbps.
  • Fast Open cookie request: 22 02 parsed as cookie=None against a bytes annotation, while one built with cookie=b'' read back b''. An absent cookie now reads b'', so parse and build agree. FastOpenCookie gets a versionchanged note.
  • Docstring: _make_mode_qs's diff is described as RFC 4782's TTL Diff.
  • Tests:
    • test_rate_parses_as_an_int covers TCP, and IPv4/HOPOPT/IPv6-Opts for both functions.
    • test_a_fast_open_cookie_request_parses_as_empty_bytes checks parse, construct from None and b'', and rebuild from info.options and to_dict(), all byte-exact.
    • Without the fix: 17 failed, 24 passed.
  • Tests run: the TCP, IPv4, HOPOPT and IPv6-Opts unit and round-trip tests, plus the docstring contract, all pass.
  • Behaviour change: a parsed cookie request's cookie is b'', not None.

… bytes (#2167)

Problem: the Quick-Start readers in TCP, IPv4, HOPOPT and IPv6-Opts
computed the rate with true division, so 80 kbps parsed as 80.0 against
an int annotation; a Fast Open cookie request (22 02) parsed as
cookie=None against a bytes annotation, while one built with cookie=b''
read back b''.

Fix: use floor division in all four (the value is always 40 * 2 ** N),
read an absent cookie as b'', and reword _make_mode_qs's diff as RFC
4782's TTL Diff.

Test: rate type checks for TCP and for IPv4/HOPOPT/IPv6-Opts, and a
cookie request parse/construct/to_dict round trip in test_tcp_udp_unit.
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 25, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at 06832a56d (Sonnet): // is exact for every rate nibble and all four readers use it, the cookie request round-trips byte-exact as b'', and 17 fail on main.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 25, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 25, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge at 06832a56d. Merging closes #2167.

  • Review: Sonnet GOOD TO GO.
  • CI: Required checks passed SUCCESS, 0 failed. Still open: the board's Sync Status.
  • KTLO: 12 legs, no warnings.
  • Ordering: the protocols leg merged into main: 1903 tests, 0 failures.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.55% (unit tier, Python 3.15, 06832a56d, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 880 2618 866 92.12%
pcapkit/corekit 2589 75 816 37 96.48%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 2971 23 1036 25 98.80%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17418 219 4574 185 98.14%
pcapkit/toolkit 869 36 298 10 95.20%
pcapkit/utilities 504 7 146 5 98.15%
pcapkit/vendor 4432 1988 1018 167 51.87%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit c210bba into main Oct 25, 2026
65 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 25, 2026
@JarryShaw
JarryShaw deleted the fix/2167-tcp-qs-fastopen-types branch October 25, 2026 14:45
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 25, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issues reporting a defect (set by the bug report template; a default, not an assessment)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(tcp): Quick-Start rate parses as float and a Fast Open cookie request as None, against their annotations

1 participant