smolpy 1.9.1.dev13__tar.gz → 1.10.1.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/PKG-INFO +3 -2
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/README.md +2 -1
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/__main__.py +19 -0
- smolpy-1.10.1.dev2/benchmarks/load.py +190 -0
- smolpy-1.10.1.dev2/benchmarks/results/2026-11-16-1839-simpy-ns3-jaws-zbook-tcp-under-load.json +504 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0004-execution-backends.md +9 -0
- smolpy-1.10.1.dev2/docs/backends.md +88 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/benchmarks.md +5 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/roadmap.md +5 -2
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/mkdocs.yml +1 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/ns3/cpp/smol-ns3.cc +38 -13
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_benchmarks.py +31 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_ns3.py +24 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/ci.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/dev-build.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/docker-image.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/docs.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/github-release.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/ns3-base.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/publish.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/release.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.github/workflows/rust-wheels.yml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/.gitignore +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/LICENSE +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/runner.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/scenarios.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/benchmarks/worker.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/Dockerfile +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/Dockerfile.dockerignore +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/Dockerfile.ns3 +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/Dockerfile.ns3.dockerignore +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/ns3-base/Dockerfile +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/ns3-base/smoke.cc +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docker/smoke.smol +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0001-protocol-package-structure.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0003-smol-external-dsl.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0005-profinet-rt.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/dashboard.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/dsl-reference.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/examples.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/index.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/language-reference.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/modbus.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/model-semantics.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/mqtt.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/profinet.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/scenario-model.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/docs/simulation-engine.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/README.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example.smol +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_10_clients.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_12_clients.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_20_clients.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_file_transfer.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_modbus.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_mqtt.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_profinet.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_profinet.smol +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_staggered_transfer.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/examples/example_two_tier.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/pyproject.toml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/Cargo.lock +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/Cargo.toml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/Cargo.toml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/src/frames.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/src/lib.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/src/rng.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/src/scenario.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/src/sim.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smol-engine/src/timebase.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smolpy-engine-rs/Cargo.toml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smolpy-engine-rs/README.md +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smolpy-engine-rs/pyproject.toml +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smolpy-engine-rs/smoke_test.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/rust/smolpy-engine-rs/src/lib.rs +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/_worker.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/backends.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/batch.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/cli.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/adapter.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/batch.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/link.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/network.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/node.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/core/observation.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/ethernet/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/ethernet/switch.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/lang/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/lang/ast.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/lang/errors.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/lang/grammar.lark +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/lang/interpreter.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/lang/transformer.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/modbus/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/modbus/slave.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/model/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/model/frames.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/model/scenario.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/model/streams.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/model/timebase.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/model/validate.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/mqtt/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/mqtt/broker.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/ns3/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/profinet/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/profinet/device.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/sim/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/sim/engine.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/stats.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/viz/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/viz/dashboard.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/src/smolpy/viz/text_dashboard.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/equivalence/__init__.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/equivalence/harness.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/equivalence/scenarios.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/equivalence/test_equivalence.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/equivalence/test_rust_timebase.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_backends.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_batch.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_cli.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_dsl.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_engine_ir.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_lang.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_model.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_profinet.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_semantics.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_simulation.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_stats.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_sweep.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_timebase.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/tests/test_validate.py +0 -0
- {smolpy-1.9.1.dev13 → smolpy-1.10.1.dev2}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: smolpy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.10.1.dev2
|
|
4
4
|
Summary: Network simulation DSL and discrete-event simulator
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -491,7 +491,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
|
|
|
491
491
|
|---|---|---|---|---|
|
|
492
492
|
| `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
|
|
493
493
|
| `rust` | Rust, through PyO3 | the whole model, headless: Ethernet, Modbus TCP, MQTT and PROFINET RT, every metric | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
|
|
494
|
-
| `ns3` | ns-3's IPv4 stack, from C++ | the whole model, headless. Ethernet over UDP and PROFINET RT on layer 2, bit-exact with SimPy. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements |
|
|
494
|
+
| `ns3` | ns-3's IPv4 stack, from C++ | the whole model, headless. Ethernet over UDP and PROFINET RT on layer 2, bit-exact with SimPy. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements | faster than SimPy on small scenarios (L1, 20 s: 0.6 s, not 3.9 s); each run is one process | the image `ghcr.io/jwszolek/smolpy:latest-ns3`, or an ns-3 3.49 build in `NS3_HOME` |
|
|
495
495
|
|
|
496
496
|
```python
|
|
497
497
|
result = net.simulate(duration=60_000, backend="rust") # one run
|
|
@@ -503,6 +503,7 @@ smolpy run plant.smol --backend rust
|
|
|
503
503
|
```
|
|
504
504
|
|
|
505
505
|
- **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses each engine's own generator, so there the results agree statistically. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
|
|
506
|
+
- **ns-3 adds TCP.** Ethernet and PROFINET on ns-3 also give SimPy's results bit for bit. Modbus and MQTT run over ns-3's TCP, so their results differ by what TCP does: under heavy load by up to +43 % in latency. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/) has the details and measurements.
|
|
506
507
|
- **Nothing is skipped silently.** A scenario that uses something a backend does not support is rejected before the run with a message naming the element. Asking the Rust engine for a dashboard is an error too.
|
|
507
508
|
|
|
508
509
|
The model both engines implement:
|
|
@@ -463,7 +463,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
|
|
|
463
463
|
|---|---|---|---|---|
|
|
464
464
|
| `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
|
|
465
465
|
| `rust` | Rust, through PyO3 | the whole model, headless: Ethernet, Modbus TCP, MQTT and PROFINET RT, every metric | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
|
|
466
|
-
| `ns3` | ns-3's IPv4 stack, from C++ | the whole model, headless. Ethernet over UDP and PROFINET RT on layer 2, bit-exact with SimPy. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements |
|
|
466
|
+
| `ns3` | ns-3's IPv4 stack, from C++ | the whole model, headless. Ethernet over UDP and PROFINET RT on layer 2, bit-exact with SimPy. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements | faster than SimPy on small scenarios (L1, 20 s: 0.6 s, not 3.9 s); each run is one process | the image `ghcr.io/jwszolek/smolpy:latest-ns3`, or an ns-3 3.49 build in `NS3_HOME` |
|
|
467
467
|
|
|
468
468
|
```python
|
|
469
469
|
result = net.simulate(duration=60_000, backend="rust") # one run
|
|
@@ -475,6 +475,7 @@ smolpy run plant.smol --backend rust
|
|
|
475
475
|
```
|
|
476
476
|
|
|
477
477
|
- **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses each engine's own generator, so there the results agree statistically. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
|
|
478
|
+
- **ns-3 adds TCP.** Ethernet and PROFINET on ns-3 also give SimPy's results bit for bit. Modbus and MQTT run over ns-3's TCP, so their results differ by what TCP does: under heavy load by up to +43 % in latency. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/) has the details and measurements.
|
|
478
479
|
- **Nothing is skipped silently.** A scenario that uses something a backend does not support is rejected before the run with a message naming the element. Asking the Rust engine for a dashboard is an error too.
|
|
479
480
|
|
|
480
481
|
The model both engines implement:
|
|
@@ -5,6 +5,8 @@ python -m benchmarks run [--scenario B1 B2 B3] [--frames 100k 1M 10M] [--metrics
|
|
|
5
5
|
python -m benchmarks summarize benchmarks/results/<file>.json
|
|
6
6
|
python -m benchmarks batch --scenario B3 --frames 1M --runs 16 --jobs 8 [--backend rust]
|
|
7
7
|
python -m benchmarks profile --scenario B1 --frames 1M --tool cprofile|tracemalloc|py-spy
|
|
8
|
+
python -m benchmarks load [--loads 0.5 0.9 1.0 1.2] [--duration 20000] [--backend simpy ns3]
|
|
9
|
+
python -m benchmarks load-summary benchmarks/results/<file>.json
|
|
8
10
|
"""
|
|
9
11
|
|
|
10
12
|
from __future__ import annotations
|
|
@@ -16,6 +18,7 @@ import subprocess
|
|
|
16
18
|
import sys
|
|
17
19
|
from pathlib import Path
|
|
18
20
|
|
|
21
|
+
from benchmarks.load import DURATION_MS, LOADS, run_load, summarize_load
|
|
19
22
|
from benchmarks.runner import parse_size, run_batch, run_suite, size_label, summarize
|
|
20
23
|
|
|
21
24
|
PROFILES_DIR = Path(__file__).parent / "profiles"
|
|
@@ -77,6 +80,16 @@ def main() -> None:
|
|
|
77
80
|
prof.add_argument("--metrics", default="off", choices=("on", "off"))
|
|
78
81
|
prof.add_argument("--tool", default="cprofile", choices=("cprofile", "tracemalloc", "py-spy"))
|
|
79
82
|
|
|
83
|
+
load = sub.add_parser("load", help="Modbus and MQTT on ns-3's TCP against SimPy, under load")
|
|
84
|
+
load.add_argument("--loads", nargs="+", type=float, default=list(LOADS))
|
|
85
|
+
load.add_argument("--duration", type=float, default=DURATION_MS, help="simulated ms")
|
|
86
|
+
load.add_argument("--backend", nargs="+", default=["simpy", "ns3"])
|
|
87
|
+
load.add_argument("--label", default="load")
|
|
88
|
+
load.add_argument("--out", type=Path, default=None)
|
|
89
|
+
|
|
90
|
+
load_summ = sub.add_parser("load-summary", help="markdown table of a load results file")
|
|
91
|
+
load_summ.add_argument("file", type=Path)
|
|
92
|
+
|
|
80
93
|
a = p.parse_args()
|
|
81
94
|
if a.cmd == "run":
|
|
82
95
|
sizes = [parse_size(s) for s in a.frames]
|
|
@@ -87,6 +100,12 @@ def main() -> None:
|
|
|
87
100
|
print(summarize(out))
|
|
88
101
|
elif a.cmd == "summarize":
|
|
89
102
|
print(summarize(a.file))
|
|
103
|
+
elif a.cmd == "load":
|
|
104
|
+
out = run_load(a.loads, a.duration, a.backend, a.label, a.out)
|
|
105
|
+
print(f"\nresults: {out}\n")
|
|
106
|
+
print(summarize_load(out, *a.backend[:2]) if len(a.backend) > 1 else "")
|
|
107
|
+
elif a.cmd == "load-summary":
|
|
108
|
+
print(summarize_load(a.file))
|
|
90
109
|
elif a.cmd == "batch":
|
|
91
110
|
frames = parse_size(a.frames)
|
|
92
111
|
r = run_batch(a.scenario, frames, a.metrics, a.runs, a.jobs, a.timeout, a.seed, a.backend)
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Modbus and MQTT over ns-3's TCP against SimPy, as a shared link loads up
|
|
2
|
+
(ADR-0004, Phase 6 exit criterion: "under load, the differences are
|
|
3
|
+
quantified and documented").
|
|
4
|
+
|
|
5
|
+
Scenario L1, a plant cell: a SCADA master polls four Modbus slaves, and two
|
|
6
|
+
sensors publish MQTT to a broker that forwards to an HMI. The slaves and
|
|
7
|
+
sensors sit behind an edge switch whose 10 Mb/s uplink to the core also
|
|
8
|
+
carries a camera's UDP stream to a recorder. The camera's rate sets the
|
|
9
|
+
offered load of the uplink, rho: the wire bits of every frame the scenario
|
|
10
|
+
sends across it (responses, PUBLISH messages, video), as a share of its
|
|
11
|
+
capacity. TCP's own acknowledgements are not part of rho: they are what
|
|
12
|
+
ns-3 adds.
|
|
13
|
+
|
|
14
|
+
Each load runs on SimPy and on ns-3 with the same samplers; the record keeps
|
|
15
|
+
each metric's mean over the run, its last sample, and the run's statistics.
|
|
16
|
+
|
|
17
|
+
python -m benchmarks load [--loads 0.5 0.9 1.0 1.2] [--duration 20000]
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import datetime as dt
|
|
23
|
+
import json
|
|
24
|
+
import math
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
from benchmarks.runner import RESULTS_DIR, environment
|
|
28
|
+
from smolpy import Network, backends
|
|
29
|
+
from smolpy.model import Scenario
|
|
30
|
+
from smolpy.model.frames import (
|
|
31
|
+
WIRE_OVERHEAD_BYTES,
|
|
32
|
+
modbus_response_frame_size,
|
|
33
|
+
mqtt_publish_frame_size,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
UPLINK_MBPS = 10
|
|
37
|
+
CAMERA_FRAME = 1_500
|
|
38
|
+
SLAVES = 4
|
|
39
|
+
POLL_RATE = 100 # polls/s per slave
|
|
40
|
+
REGISTERS = 50
|
|
41
|
+
PUBLISHES = ( # topic, rate (msg/s), payload (B), QoS
|
|
42
|
+
("cell/temp", 200, 32, 1),
|
|
43
|
+
("cell/vib", 200, 200, 0),
|
|
44
|
+
)
|
|
45
|
+
LOADS = (0.5, 0.8, 0.9, 0.95, 1.0, 1.05, 1.1, 1.2, 1.35, 1.5)
|
|
46
|
+
DURATION_MS = 20_000
|
|
47
|
+
METRICS = ("modbus_latency:scada", "latency:hmi", "bytes_received:scada", "bytes_received:hmi")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _wire_bits(frame_bytes: int) -> int:
|
|
51
|
+
return (frame_bytes + WIRE_OVERHEAD_BYTES) * 8
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def protocol_load() -> float:
|
|
55
|
+
"""The uplink's offered load without the camera: Modbus responses and
|
|
56
|
+
PUBLISH messages, as a share of its capacity."""
|
|
57
|
+
bits = SLAVES * POLL_RATE * _wire_bits(modbus_response_frame_size(REGISTERS))
|
|
58
|
+
bits += sum(
|
|
59
|
+
rate * _wire_bits(mqtt_publish_frame_size(topic, payload, qos))
|
|
60
|
+
for topic, rate, payload, qos in PUBLISHES
|
|
61
|
+
)
|
|
62
|
+
return bits / (UPLINK_MBPS * 1e6)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def scenario(rho: float, duration_ms: float = DURATION_MS) -> Scenario:
|
|
66
|
+
"""L1 with the uplink's offered load at *rho*."""
|
|
67
|
+
camera_share = rho - protocol_load()
|
|
68
|
+
if camera_share < 0:
|
|
69
|
+
raise ValueError(f"rho must be at least the protocols' own load, {protocol_load():.4f}")
|
|
70
|
+
net = Network("L1")
|
|
71
|
+
core = net.switch("core", ports=5)
|
|
72
|
+
edge = net.switch("edge", ports=SLAVES + len(PUBLISHES) + 2)
|
|
73
|
+
scada = net.adapter("scada", ip="10.0.0.1")
|
|
74
|
+
hmi = net.adapter("hmi", ip="10.0.0.2")
|
|
75
|
+
recorder = net.adapter("recorder", ip="10.0.0.3")
|
|
76
|
+
broker = net.mqtt_broker("broker", ip="10.0.0.4")
|
|
77
|
+
for node in (scada, hmi, recorder, broker):
|
|
78
|
+
net.link(node, core, speed=100, length=10)
|
|
79
|
+
net.link(edge, core, speed=UPLINK_MBPS, length=100)
|
|
80
|
+
slaves = [net.modbus_slave(f"s{i}", ip=f"10.0.1.{i + 1}", unit_id=i + 1) for i in range(SLAVES)]
|
|
81
|
+
sensors = [net.adapter(f"t{i}", ip=f"10.0.2.{i + 1}") for i in range(len(PUBLISHES))]
|
|
82
|
+
camera = net.adapter("camera", ip="10.0.3.1")
|
|
83
|
+
for node in (*slaves, *sensors, camera):
|
|
84
|
+
net.link(node, edge, speed=100, length=10)
|
|
85
|
+
for i, slave in enumerate(slaves):
|
|
86
|
+
scada.polls(slave, register=0, count=REGISTERS, rate=POLL_RATE, delay_ms=0.1 * i)
|
|
87
|
+
for i, (sensor, (topic, rate, payload, qos)) in enumerate(zip(sensors, PUBLISHES, strict=True)):
|
|
88
|
+
sensor.publishes(broker, topic=topic, rate=rate, payload=payload, qos=qos, delay_ms=i / 20)
|
|
89
|
+
broker.routes(topic, to=[hmi])
|
|
90
|
+
if camera_share > 0:
|
|
91
|
+
rate = camera_share * UPLINK_MBPS * 1e6 / _wire_bits(CAMERA_FRAME)
|
|
92
|
+
camera.sends(recorder, rate=rate, size=CAMERA_FRAME)
|
|
93
|
+
every = duration_ms / 20
|
|
94
|
+
net.observe("modbus_latency", on=scada, every=every)
|
|
95
|
+
net.observe("latency", on=hmi, every=every)
|
|
96
|
+
net.observe("bytes_received", on=scada, every=every)
|
|
97
|
+
net.observe("bytes_received", on=hmi, every=every)
|
|
98
|
+
return net.to_scenario(duration=duration_ms)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _summary(metrics: dict[str, list[tuple[float, float]]]) -> dict[str, dict[str, float]]:
|
|
102
|
+
out = {}
|
|
103
|
+
for key in METRICS:
|
|
104
|
+
values = [v for _, v in metrics[key]]
|
|
105
|
+
out[key] = {
|
|
106
|
+
"mean": sum(values) / len(values) if values else math.nan,
|
|
107
|
+
"last": values[-1] if values else math.nan,
|
|
108
|
+
}
|
|
109
|
+
return out
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def run_load(
|
|
113
|
+
loads: list[float],
|
|
114
|
+
duration_ms: float,
|
|
115
|
+
engines: list[str],
|
|
116
|
+
label: str = "load",
|
|
117
|
+
out: Path | None = None,
|
|
118
|
+
) -> Path:
|
|
119
|
+
env = environment()
|
|
120
|
+
stamp = dt.datetime.now().strftime("%Y-%m-%d-%H%M")
|
|
121
|
+
out = out or RESULTS_DIR / f"{stamp}-{'-'.join(engines)}-{env['host']}-{label}.json"
|
|
122
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
123
|
+
doc = {
|
|
124
|
+
"format": "smolpy-load",
|
|
125
|
+
"version": 1,
|
|
126
|
+
"label": label,
|
|
127
|
+
"created": dt.datetime.now().isoformat(timespec="seconds"),
|
|
128
|
+
"environment": env,
|
|
129
|
+
"scenario": "L1",
|
|
130
|
+
"duration_ms": duration_ms,
|
|
131
|
+
"uplink_mbps": UPLINK_MBPS,
|
|
132
|
+
"protocol_load": protocol_load(),
|
|
133
|
+
"runs": [],
|
|
134
|
+
}
|
|
135
|
+
for rho in loads:
|
|
136
|
+
sc = scenario(rho, duration_ms)
|
|
137
|
+
for engine in engines:
|
|
138
|
+
result = backends.get(engine).run(sc)
|
|
139
|
+
record = {
|
|
140
|
+
"rho": rho,
|
|
141
|
+
"backend": engine,
|
|
142
|
+
"events": result.stats.events,
|
|
143
|
+
"wall_s": result.stats.wall_s,
|
|
144
|
+
"metrics": _summary(result.metrics),
|
|
145
|
+
}
|
|
146
|
+
doc["runs"].append(record)
|
|
147
|
+
out.write_text(json.dumps(doc, indent=1)) # keep partial progress
|
|
148
|
+
m = record["metrics"]
|
|
149
|
+
print(
|
|
150
|
+
f"rho {rho:5.3f} {engine:6s} modbus {m[METRICS[0]]['mean'] / 1000:10.3f} ms"
|
|
151
|
+
f" mqtt {m[METRICS[1]]['mean'] / 1000:10.3f} ms"
|
|
152
|
+
f" hmi {m[METRICS[3]]['last']:.4f} MB ({record['wall_s']:.1f} s)",
|
|
153
|
+
flush=True,
|
|
154
|
+
)
|
|
155
|
+
return out
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _diff(got: float, want: float) -> str:
|
|
159
|
+
if not want or math.isnan(got) or math.isnan(want):
|
|
160
|
+
return "–"
|
|
161
|
+
return f"{100 * (got - want) / want:+.1f} %"
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def summarize_load(path: Path, reference: str = "simpy", candidate: str = "ns3") -> str:
|
|
165
|
+
"""A markdown table: each metric on the reference and the candidate."""
|
|
166
|
+
doc = json.loads(path.read_text())
|
|
167
|
+
runs = {(r["rho"], r["backend"]): r["metrics"] for r in doc["runs"]}
|
|
168
|
+
loads = sorted({rho for rho, _ in runs})
|
|
169
|
+
lines = [
|
|
170
|
+
f"L1, {doc['duration_ms'] / 1000:g} s, {doc['uplink_mbps']} Mb/s uplink;"
|
|
171
|
+
f" protocols alone: rho = {doc['protocol_load']:.3f}. {reference} → {candidate}.",
|
|
172
|
+
"",
|
|
173
|
+
"| rho | Modbus RTT, mean (ms) | MQTT latency, mean (ms) | to SCADA (MB) | to HMI (MB) |",
|
|
174
|
+
"|---|---|---|---|---|",
|
|
175
|
+
]
|
|
176
|
+
for rho in loads:
|
|
177
|
+
a, b = runs.get((rho, reference)), runs.get((rho, candidate))
|
|
178
|
+
if a is None or b is None:
|
|
179
|
+
continue
|
|
180
|
+
cells = []
|
|
181
|
+
for key, stat, scale, fmt in (
|
|
182
|
+
(METRICS[0], "mean", 1000, "{:.3f}"),
|
|
183
|
+
(METRICS[1], "mean", 1000, "{:.3f}"),
|
|
184
|
+
(METRICS[2], "last", 1, "{:.4f}"),
|
|
185
|
+
(METRICS[3], "last", 1, "{:.4f}"),
|
|
186
|
+
):
|
|
187
|
+
want, got = a[key][stat] / scale, b[key][stat] / scale
|
|
188
|
+
cells.append(f"{fmt.format(want)} → {fmt.format(got)} ({_diff(got, want)})")
|
|
189
|
+
lines.append(f"| {rho:.2f} | " + " | ".join(cells) + " |")
|
|
190
|
+
return "\n".join(lines)
|