Skip to content

Commit 4258e3e

Browse files
avrabeclaude
andcommitted
feat(trace-topology): PCAPNG FrameSource (v0.10.x B-2)
Implement the first real runtime-artefact parser on top of the v0.10.0 trace-topology foundation. `PcapngFrameSource` decodes pcapng captures from tcpdump/tshark/Wireshark into typed `CapturedFrame` records carrying mac_src, mac_dst, optional 802.1Q VLAN-ID and PCP, and a nanosecond timestamp resolved against the per-IDB ts_resol option. - Adds `pcap-parser = "0.16"` (Pierre Chifflier's crate) as the PCAPNG decoder; we own only the L2-header decode + ts conversion on top of its block iterator. - `IngestError` grows concrete kinds (`Io`, `Truncated`, `MalformedPcapng`, `UnsupportedLinkType`); `Unimplemented` stays for the LLDP/Qcc/gPTP placeholders that ship in sibling commits. - 5 unit tests (hand-built pcapng byte buffers): untagged round-trip, 802.1Q VLAN-ID + PCP extraction, truncated-frame error, unsupported-link-type error at open(), and µs vs ns ts_resol handling. Per `docs/designs/v0.10.0-trace-topology.md` §"Implementation phasing" PCAPNG entry. Maps REQ-TRACE-TOPOLOGY-003 / TEST-TRACE-TOPOLOGY-PCAPNG. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c0a8e39 commit 4258e3e

6 files changed

Lines changed: 609 additions & 34 deletions

File tree

Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

artifacts/requirements.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,4 +1833,20 @@ artifacts:
18331833
status: planned
18341834
tags: [trace-topology, track-g, v0100, crate]
18351835

1836+
- id: REQ-TRACE-TOPOLOGY-003
1837+
type: requirement
1838+
title: PCAPNG FrameSource for L2 frame ingest
1839+
description: >
1840+
System shall provide a PCAPNG-backed FrameSource implementation
1841+
in spar-trace-topology that, given a `.pcapng` file recorded
1842+
with tcpdump / tshark / Wireshark from a TAP/SPAN port, yields
1843+
a stream of CapturedFrame records carrying mac_src, mac_dst,
1844+
optional 802.1Q VLAN-ID and PCP, and a Unix-epoch ns timestamp
1845+
derived from the per-IDB ts_resol option. Built atop the
1846+
`pcap-parser` crate. Errors carry concrete kinds (Truncated,
1847+
UnsupportedLinkType, MalformedPcapng, Io). Per the v0.10.0
1848+
trace-topology design's §"Implementation phasing" PCAPNG entry.
1849+
status: implemented
1850+
tags: [trace-topology, ingest, pcapng, v0100]
1851+
18361852
# Research findings tracked separately in research/findings.yaml

artifacts/verification.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,3 +2388,23 @@ artifacts:
23882388
target: REQ-TRACE-TOPOLOGY-001
23892389
- type: satisfies
23902390
target: REQ-TRACE-TOPOLOGY-002
2391+
2392+
- id: TEST-TRACE-TOPOLOGY-PCAPNG
2393+
type: feature
2394+
title: PcapngFrameSource yields correct typed CapturedFrames
2395+
description: >
2396+
Tests in crates/spar-trace-topology/src/ingest.rs cover an
2397+
untagged Ethernet frame roundtrip, an 802.1Q-tagged frame with
2398+
VLAN-ID and PCP extraction, a truncated frame producing
2399+
IngestError::Truncated, an unsupported link type producing
2400+
IngestError::UnsupportedLinkType, and per-IDB ts_resol
2401+
handling for both µs and ns resolutions.
2402+
fields:
2403+
method: automated-test
2404+
steps:
2405+
- run: cargo test -p spar-trace-topology --lib -- ingest::tests
2406+
status: passing
2407+
tags: [trace-topology, ingest, pcapng, v0100]
2408+
links:
2409+
- type: satisfies
2410+
target: REQ-TRACE-TOPOLOGY-003

crates/spar-trace-topology/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ description = "Runtime/declared topology reconciliation for spar (PCAPNG + LLDP
1010
spar-hir-def.workspace = true
1111
spar-base-db.workspace = true
1212
spar-syntax.workspace = true
13+
pcap-parser = "0.16"
1314

1415
[dev-dependencies]
1516
tempfile = "3"

0 commit comments

Comments
 (0)