Skip to content

feat(nat-lab): capture Windows tunnel adapter traffic in pcaps (LLT-7429)#1824

Merged
gytsto merged 4 commits into
mainfrom
gytsto/LLT-7429_natlab_windows_tunnel_capture
Jul 2, 2026
Merged

feat(nat-lab): capture Windows tunnel adapter traffic in pcaps (LLT-7429)#1824
gytsto merged 4 commits into
mainfrom
gytsto/LLT-7429_natlab_windows_tunnel_capture

Conversation

@gytsto

@gytsto gytsto commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Problem

pktmon enumerates adapters only at session start, so libtelio's wireguard/wintun tunnel adapter (created later) was missing from Windows pcaps — decrypted tunnel traffic only showed up in the peer's pcap. Follow-up to #1818.

Solution

  • Capture with --comp all; poll for new adapters and roll the session (single cmd /c "pktmon stop && pktmon start") when the tunnel adapter appears.
  • Merge the resulting segments into one continuous <guest>.pcap per node, normalising in the same pass: wrap the tunnel adapter's bare-IP packets in Ethernet framing, drop the SSH control channel. Replaces the old tcpdump-based strip.

Known limitations: best-effort (depends on the tunnel adapter living long enough to roll); the brief stop→start gap shows as a small discontinuity; raw segments are kept if the merge fails.

Closes LLT-7429.

☑️ Definition of Done checklist

  • Commit history is clean (requirements)
  • README.md is updated
  • Functionality is covered by unit or integration tests

@gytsto gytsto requested a review from a team as a code owner June 17, 2026 11:26
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from 23acf50 to b2ba365 Compare June 17, 2026 12:24
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from b2ba365 to 2fdba78 Compare June 17, 2026 12:27
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from 2fdba78 to 493904e Compare June 17, 2026 12:43
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from ecb2586 to 351b203 Compare June 18, 2026 09:14

@tomasz-grz tomasz-grz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment thread nat-lab/tests/utils/tcpdump.py Outdated
Comment thread nat-lab/tests/utils/tcpdump.py Outdated
gytsto added a commit that referenced this pull request Jul 1, 2026
Address review on PR #1824:
- rename _roll -> _reload_pktmon_with_new_adapters for clarity
- name the triggering adapter(s) in the roll success log
gytsto added a commit that referenced this pull request Jul 1, 2026
Address review on PR #1824:
- rename _roll -> _reload_pktmon_with_new_adapters for clarity
- name the triggering adapter(s) in the roll success log
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from 4da8485 to ebd5b7b Compare July 1, 2026 07:10
stalowyjez
stalowyjez previously approved these changes Jul 1, 2026

@stalowyjez stalowyjez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, +1

@gytsto gytsto added this pull request to the merge queue Jul 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 1, 2026
@gytsto gytsto added this pull request to the merge queue Jul 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 1, 2026
@gytsto gytsto added this pull request to the merge queue Jul 1, 2026
@gytsto gytsto removed this pull request from the merge queue due to a manual request Jul 1, 2026
@gytsto gytsto added this pull request to the merge queue Jul 1, 2026
@gytsto gytsto removed this pull request from the merge queue due to a manual request Jul 1, 2026
gytsto added a commit that referenced this pull request Jul 1, 2026
Address review on PR #1824:
- rename _roll -> _reload_pktmon_with_new_adapters for clarity
- name the triggering adapter(s) in the roll success log
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from ebd5b7b to 12649f7 Compare July 1, 2026 18:44
@gytsto gytsto enabled auto-merge July 1, 2026 18:45
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from 5e82a64 to 12649f7 Compare July 1, 2026 19:26
gytsto added 4 commits July 2, 2026 09:28
…429)

pktmon enumerates adapters only at session start, so libtelio's
wireguard/wintun tunnel adapter - created after capture begins - was
missing from Windows pcaps; decrypted tunnel traffic was only visible in
the counterpart node's pcap.

- Capture with `--comp all` and poll for adapters that appear after
  start; roll the pktmon session (stop/restart) when one does, splitting
  the capture into numbered pcap segments.
- Normalise each downloaded pcap: wrap the tunnel adapter's bare-IP
  packets in a synthetic Ethernet header so Wireshark renders them, and
  drop the SSH control channel (unfilterable at capture time), replacing
  the old tcpdump-based strip.

Best-effort: capturing the tunnel adapter depends on it living long
enough for the roll to fire.
… one pcap

- Roll the pktmon session with one `cmd /c "pktmon stop && pktmon start"`
  instead of two SSH round-trips, shrinking the capture blind window to
  pktmon's own restart (sessions can't overlap - one per machine).
- Merge the downloaded segments into a single continuous, normalised pcap
  per node (merge_windows_pcaps) instead of leaving them as separate
  files; raw segments are kept as separate pcaps if the merge fails.
- _roll: register the new .etl and adopt the new baseline before the
  stop&&start, so a failing roll can't re-fire every poll or orphan an .etl.
- _download_pktmon_segments: guard each segment download so one bad segment
  doesn't lose the rest or skip remote cleanup.
- merge: drop only TCP/22 (SSH is TCP); use asyncio.to_thread.
- find_unique_path_for_tcpdump: drop stray ./ prefix on rolled-over names.
Address review on PR #1824:
- rename _roll -> _reload_pktmon_with_new_adapters for clarity
- name the triggering adapter(s) in the roll success log
@gytsto gytsto force-pushed the gytsto/LLT-7429_natlab_windows_tunnel_capture branch from 12649f7 to fc9f629 Compare July 2, 2026 06:30
@gytsto gytsto added this pull request to the merge queue Jul 2, 2026
Merged via the queue into main with commit edfcc33 Jul 2, 2026
58 checks passed
@gytsto gytsto deleted the gytsto/LLT-7429_natlab_windows_tunnel_capture branch July 2, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants