Skip to content

refactor(reassembly): bring DTLS reassembly to IP/TCP parity - #2605

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2531-dtls-parity
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2531-dtls-parity

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — changes neither behaviour nor performance

Description of your pull request and other information

DTLS reassembly is brought to IP/TCP parity on the two points reassembly-integration.rst listed as remaining divergences, and the page no longer lists them.

  • packet field: a reassembled DTLS Datagram now carries a packet field, decoded lazily through the shared Deferred, as IP and TCP do.
  • Deferred: it gains a (msg_type, length, message_seq) key constraint. The deferred decode runs the private pcapkit.foundation.analysis.dtls._read_handshake, and dtls_handshake remains the public entry point.
  • Unchanged: Extractor output over pcap and pcapng is the same except for the new field.

Settled on the worker's recommendations, open to the owner:

  • the deferred decode runs _read_handshake rather than self.protocol.read_handshake;
  • the shared Deferred is extended rather than given a DTLS-only placeholder;
  • an incomplete message gets packet=None under strict=False too, which keeps packet == dtls_handshake(datagram);
  • _read_handshake stays private.

It unblocks #2581 (IP and TCP analysis modules).

Closes #2531

- The DTLS Datagram is a DeferredPacket: a complete message's packet is a
  Deferred running dtls_handshake's decoder on first read, an incomplete
  one's is None.
- Deferred's type parameter admits the DTLS handshake header, and its
  analyser may return a DTLSHandshake.
- foundation.analysis.dtls moves the decode into _read_handshake, shared by
  dtls_handshake and the Deferred.
- The DTLS reassembly class sets __protocol_type__ to the DTLS protocol.
- reassembly-integration.rst no longer lists the divergences.
- New parity tests over pcap and pcapng; the Deferred and DeferredPacket
  wiring tests cover the DTLS datagram.
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 1, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at e43b95a6b (Sonnet review). Both divergences the page listed are closed, and the page no longer lists them. Extractor output over pcap and pcapng is unchanged apart from the new packet field. Every new and changed test fails on main, and pickle round trips pass at protocols 0–5. Pylint and mypy are clean on the touched modules.

@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 1, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Coverage: 94.03% (unit tier, Python 3.15, e43b95a6b, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 20093 144 2712 125 98.78%
pcapkit/corekit 2605 74 818 37 96.52%
pcapkit/dumpkit 281 3 100 3 98.43%
pcapkit/foundation 3372 27 1186 32 98.71%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 20346 220 5370 204 98.34%
pcapkit/toolkit 961 28 342 10 96.32%
pcapkit/utilities 506 7 144 5 98.15%
pcapkit/vendor 5009 2222 1148 182 52.31%

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

@github-actions github-actions Bot added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw
JarryShaw merged commit cbe28e6 into main Nov 2, 2026
67 checks passed
@JarryShaw
JarryShaw deleted the refactor/2531-dtls-parity branch November 2, 2026 02:25
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…s latest wave into 1.6.0 (#2449)

- Added: every whole HTTP/2 frame in a TCP segment is a further HTTPv2
  layer, the previous frame's payload, as with TLS (#2609).
- Folded into unreleased entries: SSLv3 lives in
  pcapkit.protocols.application.sslv3 (#2602), and a reassembled DTLS
  Datagram's packet holds the deferred handshake decode (#2605).
  tls.SSLv3 is in no release tag, so the entry records no move.
- Changed: the remaining xdist jobs at -n logical (#2606) join the CI
  entry, and the member-order entry cites the last reorder (#2613).
- No entry for the test-only #2611 and #2612, or for #2610's private
  registry sentinel, which changes no behaviour.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor(reassembly): bring DTLS reassembly to IP/TCP parity (deferred packet, __protocol_type__)

1 participant