Skip to content

Commit f46e994

Browse files
author
pseusys
committed
plotting
1 parent a8559be commit f46e994

13 files changed

Lines changed: 600 additions & 18 deletions

File tree

.github/workflows/benchmarks.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,31 @@ jobs:
9090
path: flamegraphs/
9191
retention-days: 5
9292

93+
plotting:
94+
name: Generate TYPHOON Example Plots
95+
runs-on: ubuntu-24.04
96+
97+
steps:
98+
- name: Checkout 🛎️
99+
uses: actions/checkout@v4
100+
101+
- name: Install Python and matplotlib 🐍
102+
run: pip install matplotlib numpy click rich
103+
104+
- name: Generate flow diagrams 📉
105+
env:
106+
RUSTFLAGS: "-D warnings"
107+
PYTHONPATH: evaluation/src
108+
run: |
109+
mkdir -p flow-diagrams
110+
for example in hello_world multi_flow multi_client long_session heavy_traffic; do
111+
python -m typhoon_eval.flow_plot --example "$example" --typhoon-dir typhoon --out-dir "flow-diagrams/${example}" --per-packet || true
112+
done
113+
114+
- name: Upload flow diagrams 📈
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: flow-diagrams
118+
path: flow-diagrams/
119+
retention-days: 5
120+

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ typhoon/.test_keys
1515

1616
evaluation/protocols/wireguard_daita/wg-daita/go.sum
1717
evaluation/protocols/wireguard_daita/wireguard-go
18+
19+
# Python
20+
evaluation/**/__pycache__/
21+
evaluation/**/*.pyc
22+
evaluation/**/*.pyo
23+
evaluation/.venv/
24+
evaluation/dist/
25+
evaluation/**/*.egg-info/
26+
27+
# Poetry
28+
evaluation/poetry.lock
29+
30+
# Capture results (pcaps can be hundreds of MB)
31+
evaluation/results/
32+

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The crate defines the following features:
2525
- `server`: include TYPHOON server implementation.
2626
- `client`: include TYPHOON client implementation.
2727
- `debug`: include [debug diagnostic tools](PROTOCOL.md#debug-mode) (`DebugMode`, `DebugResult`, `run_debug`, `DebugServerConnectionHandler`); requires `client` and `server`.
28+
- `capture`: emit per-packet JSONL records to the `typhoon::capture` log target at `TRACE` level; enable at runtime with `RUST_LOG=typhoon::capture=trace`.
2829
- `tokio`: use [tokio](https://tokio.rs/) async runtime.
2930
- `async-std`: use [async-std](https://async.rs/) async runtime.
3031

@@ -98,6 +99,24 @@ TYPHOON_TEST_SERVER_KEY_FAST=server.key cargo bench --bench roundtrip
9899

99100
CI runs benchmarks on every push to `main` and on pull requests that touch `typhoon/**`.
100101
Results are stored as a workflow artifact (`bench-results`) on each run.
102+
The CI also generates per-example flamegraph SVGs and per-flow packet structure diagrams
103+
(stored as `flamegraphs` and `flow-diagrams` artifacts respectively, retained for 5 days).
104+
105+
### Flow capture
106+
107+
The `capture` feature emits per-packet JSONL records (component sizes, direction, flow address)
108+
to the `typhoon::capture` log target at `TRACE` level. The `evaluation/` tool can turn these
109+
into stacked-bar SVG diagrams:
110+
111+
```shell
112+
# Run an example, capture traffic, generate diagrams
113+
cd evaluation
114+
poe plot --example heavy_traffic --out-dir out/
115+
116+
# Or generate from an existing log file
117+
RUST_LOG=typhoon::capture=trace cargo run --features capture --example hello_world 2>trace.log
118+
poe plot --log trace.log --out-dir out/
119+
```
101120

102121
### Coverage
103122

evaluation/.gitignore

Lines changed: 0 additions & 13 deletions
This file was deleted.

evaluation/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ rich = "^13.0"
1212
python-on-whales = "^0.73"
1313
scapy = "^2.6"
1414
numpy = "^2.0"
15+
matplotlib = "^3.9"
1516

1617
[tool.poetry.group.dev.dependencies]
1718
ruff = "^0.11"
@@ -48,6 +49,10 @@ select = ["E", "F", "I", "UP", "B"]
4849
cmd = "python -m typhoon_eval.analysis"
4950
help = "Analyze captured pcap files — pass --run <YYYYMMDD_HHMMSS> or omit for latest"
5051

52+
[tool.poe.tasks.plot]
53+
cmd = "python -m typhoon_eval.flow_plot"
54+
help = "Generate per-flow packet structure diagrams — pass --example <name> or --log <file>, and --out-dir <dir>"
55+
5156
[tool.poe.tasks.clean]
5257
shell = "rm -rf results/captures results/logs"
5358
help = "Delete all captured pcap files and logs"

0 commit comments

Comments
 (0)