Repository navigation
fix(engines): write real PCAP traces for dpkt and scapy (#1507) - #1511
Conversation
|
Verdict: NEEDS CHANGES at Blocking: wrong timestamps on nanosecond PCAP-NG (
Should fix:
Confirmed: byte identity with the default engine on 6 real captures, synthetic µs/ms PCAP-NG and nanosecond classic PCAP; mixed link types on dpkt; fail-before 9 + 30 failures; with the fix, 33 passed and 102 subtests. |
b2b57e2 to
508e3aa
Compare
|
Verdict: NEEDS CHANGES at Fixed since round 1: traces are now byte-identical with the default engine on all nanosecond PCAP-NG and PCAP cases, both aligned and unaligned. dpkt PCAP-NG now writes Still needs changing:
Nits: Pre-existing: scapy's interface table goes stale after a second Section Header Block ( |
|
Coverage: 89.99% (unit tier, Python 3.14,
Per-file detail: the |
508e3aa to
d8d631e
Compare
d8d631e to
0eed63f
Compare
|
Verdict: GOOD TO GO on its own content at What the reviewer confirmed:
Required: #1508 has merged, so its dpkt and scapy Hardening in the same push:
|
|
Verdict: GOOD TO GO at
Nit, not blocking: this PR shifts lines that the |
|
Verdict: NEEDS CHANGES. Do not merge as-is. Merged into current
|
- toolkit/dpkt, toolkit/scapy: tcp_traceflow reports a FrameRecord, the engine's packet2dict mapping as before, carrying the captured octets, the PCAP record header and the exact time_epoch that only the PCAP trace dumper reads. - engines/dpkt: the PCAP and PCAP-NG readers yield a Timestamp (float) or, for a nanosecond PCAP, a DecimalTimestamp: the value dpkt yields, carrying the exact timestamp, the resolution and the original length. Under a dpkt without the reader internals this relies on, it reads with dpkt's own loop and warns. - engines/scapy: captures are read through PcapReader subclasses that stamp each packet with its PCAP or PCAP-NG interface resolution, and close once. - foundation/traceflow/data: new FrameRecord, a dict with packet, frame_info and time_epoch attributes, picklable with every protocol. - foundation/extraction, interface/misc: dpkt and scapy leave the trace_format='pcap' -> JSON fallback; #1508's Gap(1507) keeps pypcapfile. Traced PCAP files are byte-identical to the default engine's at both trace resolutions, and JSON, plist and tree output byte-identical to main's.
0eed63f to
8e87770
Compare
|
Verdict: GOOD TO GO at
Nit, not blocking: the |
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Both engines expose the frame bytes, so
trace_format='pcap'now writes real PCAP instead of falling back to JSON.tcp_traceflowstill reports main'spacket2dictmapping, as aFrameRecord(a picklable dict). Itspacket,frame_infoand exact-Decimaltime_epochattributes are read only by the PCAP dumper; fix(dumpkit): scale a PCAP trace record's fraction to the trace's resolution (#1500) #1529's_make_timestampinfers the record's resolution fromtime_epoch. JSON, plist and tree output is byte-identical to main; the JSON trace oftcp.pcapis pinned by hash.dpkt.pcap.Readersubclass yield aTimestamp(float), or aDecimalTimestampfor nanosecond PCAP. Each is dpkt's own value and type, also carrying the exact time, the resolution andorig_len, so fix(engines): the dpkt engine passes a Decimal timestamp for nanosecond PCAP #1501 is untouched; a plainDecimalwould spread its mismatch to every reassembly input and flow label. Under a dpkt lackingReader's private_Reader__f/_Reader__ph/_divisor, the subclass falls back to dpkt's loop with aDPKTWarningnaming the version.PcapReader/PcapNgReadersubclasses passed tosniff(opened_socket=…), which stamp each packet with its PCAP or interface resolution, because scapy dropstsresol. A guardedclose()in afinallycovers a raisingsniffwithout double-closing gzip readers.Gap(1507)dpkt and scapy flow rows are deleted; the pypcapfile part stays, as pypcapfile still falls back.trace_nanosecondsettings, on 5 real captures and synthetic ns PCAP andif_tsresol=9PCAP-NG captures, unaligned and µs-aligned, including the cross-resolution rescale and snapped frames. The new file had 7 failures against508e3aad0; it now passes 11 tests and 80 subtests.main: scapy raisesMissingKeyError('IP')on raw-IP (101) PCAP-NG frames. The engines also group different frames into flows on snapped/TSO captures, and scapy itself misdates a second PCAP-NG section.Refs #1507