smolpy 1.8.2.dev2__tar.gz → 1.8.2.dev8__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.
Files changed (136) hide show
  1. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/PKG-INFO +15 -4
  2. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/README.md +14 -3
  3. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/dsl-reference.md +3 -3
  4. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/roadmap.md +9 -0
  5. smolpy-1.8.2.dev8/rust/smol-engine/src/frames.rs +63 -0
  6. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smol-engine/src/scenario.rs +161 -20
  7. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smol-engine/src/sim.rs +336 -21
  8. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/README.md +3 -1
  9. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/equivalence/scenarios.py +77 -0
  10. smolpy-1.8.2.dev2/rust/smol-engine/src/frames.rs +0 -29
  11. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/ci.yml +0 -0
  12. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/dev-build.yml +0 -0
  13. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/docs.yml +0 -0
  14. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/github-release.yml +0 -0
  15. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/publish.yml +0 -0
  16. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/release.yml +0 -0
  17. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.github/workflows/rust-wheels.yml +0 -0
  18. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/.gitignore +0 -0
  19. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/LICENSE +0 -0
  20. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/__init__.py +0 -0
  21. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/__main__.py +0 -0
  22. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  23. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  24. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  25. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  26. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  27. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  28. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  29. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/runner.py +0 -0
  30. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/scenarios.py +0 -0
  31. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/benchmarks/worker.py +0 -0
  32. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0001-protocol-package-structure.md +0 -0
  33. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  34. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0003-smol-external-dsl.md +0 -0
  35. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0004-execution-backends.md +0 -0
  36. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0005-profinet-rt.md +0 -0
  37. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  38. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  39. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  40. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +0 -0
  41. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  42. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/benchmarks.md +0 -0
  43. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/dashboard.md +0 -0
  44. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/examples.md +0 -0
  45. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/index.md +0 -0
  46. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/language-reference.md +0 -0
  47. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/modbus.md +0 -0
  48. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/model-semantics.md +0 -0
  49. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/mqtt.md +0 -0
  50. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/profinet.md +0 -0
  51. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/scenario-model.md +0 -0
  52. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/docs/simulation-engine.md +0 -0
  53. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/README.md +0 -0
  54. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example.py +0 -0
  55. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example.smol +0 -0
  56. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_10_clients.py +0 -0
  57. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_12_clients.py +0 -0
  58. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_20_clients.py +0 -0
  59. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_file_transfer.py +0 -0
  60. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_modbus.py +0 -0
  61. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_mqtt.py +0 -0
  62. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_profinet.py +0 -0
  63. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_profinet.smol +0 -0
  64. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_staggered_transfer.py +0 -0
  65. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/examples/example_two_tier.py +0 -0
  66. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/mkdocs.yml +0 -0
  67. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/pyproject.toml +0 -0
  68. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/Cargo.lock +0 -0
  69. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/Cargo.toml +0 -0
  70. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smol-engine/Cargo.toml +0 -0
  71. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smol-engine/src/lib.rs +0 -0
  72. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smol-engine/src/rng.rs +0 -0
  73. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smol-engine/src/timebase.rs +0 -0
  74. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  75. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  76. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  77. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  78. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/__init__.py +0 -0
  79. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/_worker.py +0 -0
  80. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/backends.py +0 -0
  81. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/batch.py +0 -0
  82. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/cli.py +0 -0
  83. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/__init__.py +0 -0
  84. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/adapter.py +0 -0
  85. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/batch.py +0 -0
  86. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/link.py +0 -0
  87. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/network.py +0 -0
  88. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/node.py +0 -0
  89. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/core/observation.py +0 -0
  90. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/ethernet/__init__.py +0 -0
  91. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/ethernet/switch.py +0 -0
  92. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/lang/__init__.py +0 -0
  93. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/lang/ast.py +0 -0
  94. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/lang/errors.py +0 -0
  95. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/lang/grammar.lark +0 -0
  96. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/lang/interpreter.py +0 -0
  97. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/lang/transformer.py +0 -0
  98. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/modbus/__init__.py +0 -0
  99. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/modbus/slave.py +0 -0
  100. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/model/__init__.py +0 -0
  101. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/model/frames.py +0 -0
  102. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/model/scenario.py +0 -0
  103. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/model/streams.py +0 -0
  104. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/model/timebase.py +0 -0
  105. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/model/validate.py +0 -0
  106. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/mqtt/__init__.py +0 -0
  107. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/mqtt/broker.py +0 -0
  108. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/profinet/__init__.py +0 -0
  109. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/profinet/device.py +0 -0
  110. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/sim/__init__.py +0 -0
  111. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/sim/engine.py +0 -0
  112. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/stats.py +0 -0
  113. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/viz/__init__.py +0 -0
  114. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/viz/dashboard.py +0 -0
  115. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/src/smolpy/viz/text_dashboard.py +0 -0
  116. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/__init__.py +0 -0
  117. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/equivalence/__init__.py +0 -0
  118. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/equivalence/harness.py +0 -0
  119. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/equivalence/test_equivalence.py +0 -0
  120. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/equivalence/test_rust_timebase.py +0 -0
  121. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_backends.py +0 -0
  122. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_batch.py +0 -0
  123. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_benchmarks.py +0 -0
  124. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_cli.py +0 -0
  125. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_dsl.py +0 -0
  126. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_engine_ir.py +0 -0
  127. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_lang.py +0 -0
  128. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_model.py +0 -0
  129. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_profinet.py +0 -0
  130. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_semantics.py +0 -0
  131. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_simulation.py +0 -0
  132. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_stats.py +0 -0
  133. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_sweep.py +0 -0
  134. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_timebase.py +0 -0
  135. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/tests/test_validate.py +0 -0
  136. {smolpy-1.8.2.dev2 → smolpy-1.8.2.dev8}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: smolpy
3
- Version: 1.8.2.dev2
3
+ Version: 1.8.2.dev8
4
4
  Summary: Network simulation DSL and discrete-event simulator
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -30,6 +30,7 @@ Description-Content-Type: text/markdown
30
30
 
31
31
  [![CI](https://github.com/jwszolek/SMOLPy/actions/workflows/ci.yml/badge.svg)](https://github.com/jwszolek/SMOLPy/actions/workflows/ci.yml)
32
32
  [![PyPI version](https://img.shields.io/pypi/v/smolpy)](https://pypi.org/project/smolpy/)
33
+ [![Dev build](https://img.shields.io/github/v/release/jwszolek/SMOLPy?include_prereleases&filter=Development%2A&display_name=release&label=main)](https://github.com/jwszolek/SMOLPy/releases/tag/dev)
33
34
  [![Python](https://img.shields.io/pypi/pyversions/smolpy)](https://pypi.org/project/smolpy/)
34
35
  [![License](https://img.shields.io/github/license/jwszolek/SMOLPy)](LICENSE)
35
36
  [![Docs](https://img.shields.io/badge/docs-mkdocs--material-blue)](https://jwszolek.github.io/SMOLPy/)
@@ -47,7 +48,7 @@ SMOLPy lets you describe a network topology in pure Python, define traffic flows
47
48
  > result = net.simulate(duration=60_000, backend="rust")
48
49
  > ```
49
50
  >
50
- > The Rust engine covers Ethernet for now: adapters, switches, links and flows. MQTT, Modbus TCP and PROFINET follow. See [Simulation engine](#simulation-engine) and [ADR-0008](https://jwszolek.github.io/SMOLPy/adr/0008-rust-des-engine-mvp/).
51
+ > The Rust engine covers Ethernet, Modbus TCP and MQTT for now: adapters, switches, links, flows, Modbus polling and MQTT publish/subscribe. PROFINET follows. See [Simulation engine](#simulation-engine) and [ADR-0008](https://jwszolek.github.io/SMOLPy/adr/0008-rust-des-engine-mvp/).
51
52
 
52
53
  📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
53
54
 
@@ -76,7 +77,17 @@ pip install "smolpy[rust]" # plus the native Rust engine, about 40x faster
76
77
  pip install --pre "smolpy[rust]" # the latest development build of main
77
78
  ```
78
79
 
79
- Every merge to `main` that changes the package publishes a **development build**, `X.Y.(Z+1).devN` (N commits after the latest release). It is a pre-release on PyPI, so `pip` installs it only with `--pre`, and the GitHub pre-release [Development build](https://github.com/jwszolek/SMOLPy/releases/tag/dev) points to its commit. Releases proper are made by hand.
80
+ **Release channels.** The versions below are read live from PyPI and GitHub, so this table is always current:
81
+
82
+ | Channel | smolpy | smolpy-engine-rs | Install |
83
+ |---|---|---|---|
84
+ | **Stable**, released by hand | [![smolpy](https://img.shields.io/pypi/v/smolpy?label=)](https://pypi.org/project/smolpy/) | [![smolpy-engine-rs](https://img.shields.io/pypi/v/smolpy-engine-rs?label=)](https://pypi.org/project/smolpy-engine-rs/) | `pip install "smolpy[rust]"` |
85
+ | **Development**, every merge to `main` | [![dev](https://img.shields.io/github/v/release/jwszolek/SMOLPy?include_prereleases&filter=Development%2A&display_name=release&label=)](https://github.com/jwszolek/SMOLPy/releases/tag/dev) | same version | `pip install --pre "smolpy[rust]"` |
86
+
87
+ - **What a development build is.** Every merge to `main` that changes the package publishes one, as `X.Y.(Z+1).devN`, N commits after the latest release.
88
+ - **How to get it.** It is a pre-release on PyPI, so `pip` installs it only with `--pre`.
89
+ - **Where it is on GitHub.** The [Development build](https://github.com/jwszolek/SMOLPy/releases/tag/dev) pre-release points to its commit.
90
+ - **Releases proper** are made by hand.
80
91
 
81
92
  From a clone, for development:
82
93
 
@@ -460,7 +471,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
460
471
  | Backend | Language | What it runs | Speed | Install |
461
472
  |---|---|---|---|---|
462
473
  | `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
463
- | `rust` | Rust, through PyO3 | Ethernet: adapters, switches, links, flows (constant, Poisson, bursty, batch, IMIX), six metrics | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
474
+ | `rust` | Rust, through PyO3 | Ethernet: adapters, switches, links, flows (constant, Poisson, bursty, batch, IMIX); Modbus TCP polling; seven metrics | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
464
475
 
465
476
  ```python
466
477
  result = net.simulate(duration=60_000, backend="rust") # one run
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/jwszolek/SMOLPy/actions/workflows/ci.yml/badge.svg)](https://github.com/jwszolek/SMOLPy/actions/workflows/ci.yml)
4
4
  [![PyPI version](https://img.shields.io/pypi/v/smolpy)](https://pypi.org/project/smolpy/)
5
+ [![Dev build](https://img.shields.io/github/v/release/jwszolek/SMOLPy?include_prereleases&filter=Development%2A&display_name=release&label=main)](https://github.com/jwszolek/SMOLPy/releases/tag/dev)
5
6
  [![Python](https://img.shields.io/pypi/pyversions/smolpy)](https://pypi.org/project/smolpy/)
6
7
  [![License](https://img.shields.io/github/license/jwszolek/SMOLPy)](LICENSE)
7
8
  [![Docs](https://img.shields.io/badge/docs-mkdocs--material-blue)](https://jwszolek.github.io/SMOLPy/)
@@ -19,7 +20,7 @@ SMOLPy lets you describe a network topology in pure Python, define traffic flows
19
20
  > result = net.simulate(duration=60_000, backend="rust")
20
21
  > ```
21
22
  >
22
- > The Rust engine covers Ethernet for now: adapters, switches, links and flows. MQTT, Modbus TCP and PROFINET follow. See [Simulation engine](#simulation-engine) and [ADR-0008](https://jwszolek.github.io/SMOLPy/adr/0008-rust-des-engine-mvp/).
23
+ > The Rust engine covers Ethernet, Modbus TCP and MQTT for now: adapters, switches, links, flows, Modbus polling and MQTT publish/subscribe. PROFINET follows. See [Simulation engine](#simulation-engine) and [ADR-0008](https://jwszolek.github.io/SMOLPy/adr/0008-rust-des-engine-mvp/).
23
24
 
24
25
  📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
25
26
 
@@ -48,7 +49,17 @@ pip install "smolpy[rust]" # plus the native Rust engine, about 40x faster
48
49
  pip install --pre "smolpy[rust]" # the latest development build of main
49
50
  ```
50
51
 
51
- Every merge to `main` that changes the package publishes a **development build**, `X.Y.(Z+1).devN` (N commits after the latest release). It is a pre-release on PyPI, so `pip` installs it only with `--pre`, and the GitHub pre-release [Development build](https://github.com/jwszolek/SMOLPy/releases/tag/dev) points to its commit. Releases proper are made by hand.
52
+ **Release channels.** The versions below are read live from PyPI and GitHub, so this table is always current:
53
+
54
+ | Channel | smolpy | smolpy-engine-rs | Install |
55
+ |---|---|---|---|
56
+ | **Stable**, released by hand | [![smolpy](https://img.shields.io/pypi/v/smolpy?label=)](https://pypi.org/project/smolpy/) | [![smolpy-engine-rs](https://img.shields.io/pypi/v/smolpy-engine-rs?label=)](https://pypi.org/project/smolpy-engine-rs/) | `pip install "smolpy[rust]"` |
57
+ | **Development**, every merge to `main` | [![dev](https://img.shields.io/github/v/release/jwszolek/SMOLPy?include_prereleases&filter=Development%2A&display_name=release&label=)](https://github.com/jwszolek/SMOLPy/releases/tag/dev) | same version | `pip install --pre "smolpy[rust]"` |
58
+
59
+ - **What a development build is.** Every merge to `main` that changes the package publishes one, as `X.Y.(Z+1).devN`, N commits after the latest release.
60
+ - **How to get it.** It is a pre-release on PyPI, so `pip` installs it only with `--pre`.
61
+ - **Where it is on GitHub.** The [Development build](https://github.com/jwszolek/SMOLPy/releases/tag/dev) pre-release points to its commit.
62
+ - **Releases proper** are made by hand.
52
63
 
53
64
  From a clone, for development:
54
65
 
@@ -432,7 +443,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
432
443
  | Backend | Language | What it runs | Speed | Install |
433
444
  |---|---|---|---|---|
434
445
  | `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
435
- | `rust` | Rust, through PyO3 | Ethernet: adapters, switches, links, flows (constant, Poisson, bursty, batch, IMIX), six metrics | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
446
+ | `rust` | Rust, through PyO3 | Ethernet: adapters, switches, links, flows (constant, Poisson, bursty, batch, IMIX); Modbus TCP polling; seven metrics | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
436
447
 
437
448
  ```python
438
449
  result = net.simulate(duration=60_000, backend="rust") # one run
@@ -166,13 +166,13 @@ result.export("out.csv", format="csv") # explicit format override
166
166
  | `"simpy"` | The reference implementation. It is the default, always installed, and runs the whole model, including the live and text dashboards. |
167
167
  | `"rust"` | The native engine of [ADR-0008](adr/0008-rust-des-engine-mvp.md), from the optional package `smolpy-engine-rs` (`pip install smolpy[rust]`). It runs headless. |
168
168
 
169
- - **What a backend can run is checked before the run.** Every backend declares what it supports: node kinds, traffic kinds, patterns and metrics. A scenario that uses anything else is rejected with a `ScenarioError` naming the element, for example `poll a -> meter: the rust backend does not support poll (Modbus TCP)`.
169
+ - **What a backend can run is checked before the run.** Every backend declares what it supports: node kinds, traffic kinds, patterns and metrics. A scenario that uses anything else is rejected with a `ScenarioError` naming the element, for example `ProfinetDevice 'io': the rust backend does not support PROFINET device (planned for Phase 5)`.
170
170
  - **A missing backend is an error.** When a backend is not installed, selecting it raises `BackendUnavailable` with the install command.
171
171
  - **`smolpy.backends.installed()`** lists the backends that can run here.
172
172
 
173
- **The Rust backend so far** runs adapters, switches (`strict` and `fifo` QoS, `learning` and `topology` MAC tables), links and flows with every pattern (`constant`, `poisson`, `bursty`, `batch`) and with fixed or IMIX sizes. It covers the metrics `throughput`, `latency`, `bytes_sent`, `bytes_received`, `queue_depth` and `utilization`.
173
+ **The Rust backend so far** runs adapters, switches (`strict` and `fifo` QoS, `learning` and `topology` MAC tables), links and flows with every pattern (`constant`, `poisson`, `bursty`, `batch`) and with fixed or IMIX sizes. It also runs Modbus TCP (slaves, `polls()` and `modbus_latency`) and MQTT (brokers, `publishes()` with QoS 0 and 1, `routes()` and `broker_queue`). It covers every metric except the PROFINET ones.
174
174
  - **Same results as SimPy.** Deterministic scenarios give SimPy's results bit for bit. Random traffic uses the same streams and distributions with the engine's own generator, so there the results agree statistically.
175
- - **Not in it yet.** MQTT, Modbus and PROFINET come in Phase 5 of the [roadmap](roadmap.md).
175
+ - **Not in it yet.** PROFINET comes in Phase 5 of the [roadmap](roadmap.md).
176
176
  - **Install** it with `pip install smolpy[rust]`, or `pip install smolpy-engine-rs` next to an installed `smolpy`. It is released together with `smolpy`, with the same version, since v1.8.0. Wheels exist for Linux x86_64 and aarch64, macOS arm64 and x86_64, and Windows x86_64. To build it from the repository instead, with a Rust toolchain:
177
177
 
178
178
  ```bash
@@ -153,6 +153,15 @@ Modbus TCP, MQTT and PROFINET RT in the Rust engine. These need no new architect
153
153
 
154
154
  **Exit criteria:** the Rust backend's capabilities equal SimPy's, apart from the live dashboard.
155
155
 
156
+ **Status:** two of three protocols done.
157
+ - **Modbus TCP: done.**
158
+ - The Rust engine runs slaves, `polls()` and `modbus_latency`. It reproduces SimPy's poll generator and slave process, including requests flooded to other slaves and dropped there.
159
+ - The new `polling` scenario is bit-exact with SimPy, down to the event count.
160
+ - **MQTT: done.**
161
+ - The Rust engine runs brokers, `publishes()` with QoS 0 and 1, `routes()` and `broker_queue`. It reproduces SimPy's publish generator and broker: copies keep the publisher's origin time, QoS 1 is acknowledged with a PUBACK, and a topic nobody subscribes to is only acknowledged.
162
+ - The new `messaging` scenario (two brokers, non-ASCII topics) and the existing `protocols` scenario (Modbus and MQTT) are bit-exact with SimPy, down to the event count.
163
+ - **PROFINET RT** is next. Its watchdog waits on "a frame or a timeout", a SimPy condition whose event ordering the engine has to reproduce. watchdog waits on "a frame or a timeout", a SimPy condition whose event ordering the engine has to reproduce.
164
+
156
165
  ## Phase 6: ns-3 high-fidelity backend ([ADR-0004](adr/0004-execution-backends.md), revised)
157
166
 
158
167
  A code-generated ns-3 scenario from the Scenario IR. Gives a realistic TCP/IP stack for Modbus and MQTT.
@@ -0,0 +1,63 @@
1
+ //! Ethernet frames on the wire (ADR-0010), as `smolpy.model.frames`.
2
+ //!
3
+ //! A frame runs from the destination MAC to the FCS, is at least 64 B and
4
+ //! carries an 802.1Q tag with a priority above 0. On the wire every frame is
5
+ //! preceded by a preamble and SFD (8 B) and followed by an inter-frame gap
6
+ //! (12 B).
7
+
8
+ pub const VLAN_TAG_BYTES: u64 = 4;
9
+ pub const PREAMBLE_SFD_BYTES: u64 = 8;
10
+ pub const IFG_BYTES: u64 = 12;
11
+ pub const WIRE_OVERHEAD_BYTES: u64 = PREAMBLE_SFD_BYTES + IFG_BYTES;
12
+
13
+ pub const MIN_FRAME_BYTES: u64 = 64;
14
+ /// Ethernet header (14), IPv4 (20), TCP (20) and FCS (4).
15
+ pub const ETHERNET_IP_TCP_BYTES: u64 = 14 + 20 + 20 + 4;
16
+ /// Modbus TCP Read Holding Registers request: MBAP (6), FC, address, quantity.
17
+ pub const MODBUS_REQUEST_BYTES: u64 = ETHERNET_IP_TCP_BYTES + 6 + 1 + 2 + 2;
18
+
19
+ /// A frame padded to the 64 B Ethernet minimum.
20
+ pub fn padded(bytes: u64) -> u64 {
21
+ bytes.max(MIN_FRAME_BYTES)
22
+ }
23
+
24
+ /// MQTT PUBACK: fixed header (2) and packet id (2).
25
+ pub const MQTT_PUBACK_BYTES: u64 = 64; // 62 B, padded to the minimum
26
+
27
+ /// MQTT PUBLISH: fixed header (2), topic length (2), the topic, a packet id
28
+ /// with a QoS above 0 (2) and the payload. `topic_len` counts characters, as
29
+ /// the reference engine's `len(topic)`.
30
+ pub fn mqtt_publish_frame_size(topic_len: u64, payload: u64, qos: u8) -> u64 {
31
+ padded(ETHERNET_IP_TCP_BYTES + 2 + 2 + topic_len + if qos > 0 { 2 } else { 0 } + payload)
32
+ }
33
+
34
+ /// Read Holding Registers response: MBAP (6), FC (1), byte count (1), 2 B per register.
35
+ pub fn modbus_response_frame_size(count: u16) -> u64 {
36
+ padded(ETHERNET_IP_TCP_BYTES + 6 + 1 + 1 + 2 * count as u64)
37
+ }
38
+
39
+ /// A flow frame of `size` bytes (untagged, FCS included), with the tag a
40
+ /// priority above 0 needs.
41
+ pub fn flow_frame_size(size: u64, priority: u8) -> u64 {
42
+ size + if priority > 0 { VLAN_TAG_BYTES } else { 0 }
43
+ }
44
+
45
+ #[cfg(test)]
46
+ mod tests {
47
+ use super::*;
48
+
49
+ #[test]
50
+ fn flow_frames() {
51
+ assert_eq!(flow_frame_size(100, 0), 100);
52
+ assert_eq!(flow_frame_size(100, 3), 104);
53
+ assert_eq!(WIRE_OVERHEAD_BYTES, 20);
54
+ // the values of tests/test_semantics.py::test_frame_sizes
55
+ assert_eq!(MODBUS_REQUEST_BYTES, 69);
56
+ assert_eq!(modbus_response_frame_size(10), 86);
57
+ assert_eq!(modbus_response_frame_size(1), 68);
58
+ assert_eq!(MQTT_PUBACK_BYTES, padded(ETHERNET_IP_TCP_BYTES + 4));
59
+ assert_eq!(mqtt_publish_frame_size(7, 20, 0), 58 + 2 + 2 + 7 + 20);
60
+ assert_eq!(mqtt_publish_frame_size(7, 20, 1), 58 + 2 + 2 + 7 + 2 + 20);
61
+ assert_eq!(mqtt_publish_frame_size(1, 0, 0), 64);
62
+ }
63
+ }
@@ -15,6 +15,8 @@ pub const VERSION: u64 = 2;
15
15
  #[derive(Debug, Clone)]
16
16
  pub enum NodeKind {
17
17
  Adapter { mac: String },
18
+ ModbusSlave { mac: String, unit: u8 },
19
+ MqttBroker { mac: String },
18
20
  Switch { fifo: bool, topology: bool },
19
21
  }
20
22
 
@@ -58,6 +60,36 @@ pub struct Flow {
58
60
  pub priority: u8,
59
61
  }
60
62
 
63
+ /// Modbus TCP polling (FC 03): `count` registers at `rate` polls per second.
64
+ #[derive(Debug, Clone)]
65
+ pub struct Poll {
66
+ pub source: String,
67
+ pub slave: String,
68
+ pub count: u16,
69
+ pub rate: Q,
70
+ pub delay_ms: Q,
71
+ }
72
+
73
+ /// MQTT PUBLISH messages to a broker at `rate` messages per second.
74
+ #[derive(Debug, Clone)]
75
+ pub struct Publish {
76
+ pub source: String,
77
+ pub broker: String,
78
+ pub topic: String,
79
+ pub rate: Q,
80
+ pub payload: u64,
81
+ pub qos: u8,
82
+ pub delay_ms: Q,
83
+ }
84
+
85
+ /// A broker's fan-out of one topic to its subscribers.
86
+ #[derive(Debug, Clone)]
87
+ pub struct Route {
88
+ pub broker: String,
89
+ pub topic: String,
90
+ pub subscribers: Vec<String>,
91
+ }
92
+
61
93
  #[derive(Debug, Clone, Copy, PartialEq, Eq)]
62
94
  pub enum Metric {
63
95
  Throughput,
@@ -66,16 +98,20 @@ pub enum Metric {
66
98
  BytesReceived,
67
99
  QueueDepth,
68
100
  Utilization,
101
+ ModbusLatency,
102
+ BrokerQueue,
69
103
  }
70
104
 
71
105
  impl Metric {
72
- pub const ALL: [(&'static str, Metric); 6] = [
106
+ pub const ALL: [(&'static str, Metric); 8] = [
73
107
  ("throughput", Metric::Throughput),
74
108
  ("latency", Metric::Latency),
75
109
  ("bytes_sent", Metric::BytesSent),
76
110
  ("bytes_received", Metric::BytesReceived),
77
111
  ("queue_depth", Metric::QueueDepth),
78
112
  ("utilization", Metric::Utilization),
113
+ ("modbus_latency", Metric::ModbusLatency),
114
+ ("broker_queue", Metric::BrokerQueue),
79
115
  ];
80
116
 
81
117
  pub fn name(self) -> &'static str {
@@ -96,6 +132,9 @@ pub struct Scenario {
96
132
  pub nodes: Vec<Node>,
97
133
  pub links: Vec<Link>,
98
134
  pub flows: Vec<Flow>,
135
+ pub polls: Vec<Poll>,
136
+ pub publishes: Vec<Publish>,
137
+ pub routes: Vec<Route>,
99
138
  pub observations: Vec<Observation>,
100
139
  pub duration_ms: Q,
101
140
  pub seed: u64,
@@ -112,8 +151,8 @@ pub struct Capabilities {
112
151
  }
113
152
 
114
153
  pub const CAPABILITIES: Capabilities = Capabilities {
115
- nodes: &["adapter", "switch"],
116
- traffic: &["flow"],
154
+ nodes: &["adapter", "switch", "modbus_slave", "mqtt_broker"],
155
+ traffic: &["flow", "poll", "publish", "route"],
117
156
  patterns: &["constant", "poisson", "bursty", "batch"],
118
157
  metrics: &[
119
158
  "throughput",
@@ -122,15 +161,12 @@ pub const CAPABILITIES: Capabilities = Capabilities {
122
161
  "bytes_received",
123
162
  "queue_depth",
124
163
  "utilization",
164
+ "modbus_latency",
165
+ "broker_queue",
125
166
  ],
126
167
  features: &["imix"],
127
168
  notes: &[
128
- ("mqtt_broker", "planned for Phase 5"),
129
- ("modbus_slave", "planned for Phase 5"),
130
169
  ("profinet_device", "planned for Phase 5"),
131
- ("publish", "planned for Phase 5"),
132
- ("route", "planned for Phase 5"),
133
- ("poll", "planned for Phase 5"),
134
170
  ("profinet_ar", "planned for Phase 5"),
135
171
  ],
136
172
  };
@@ -256,12 +292,18 @@ pub fn parse(text: &str) -> Res<Scenario> {
256
292
  f.done()?;
257
293
  links.push(link);
258
294
  }
259
- let mut flows = Vec::new();
295
+ let (mut flows, mut polls, mut publishes, mut routes) =
296
+ (Vec::new(), Vec::new(), Vec::new(), Vec::new());
260
297
  for (i, v) in array(top.take_or("traffic"), "traffic")?
261
298
  .into_iter()
262
299
  .enumerate()
263
300
  {
264
- flows.push(parse_traffic(v, i)?);
301
+ match parse_traffic(v, i)? {
302
+ Traffic::Flow(flow) => flows.push(flow),
303
+ Traffic::Poll(poll) => polls.push(poll),
304
+ Traffic::Publish(publish) => publishes.push(publish),
305
+ Traffic::Route(route) => routes.push(route),
306
+ }
265
307
  }
266
308
  let mut observations = Vec::new();
267
309
  for (i, v) in array(top.take_or("observations"), "observations")?
@@ -305,6 +347,9 @@ pub fn parse(text: &str) -> Res<Scenario> {
305
347
  nodes,
306
348
  links,
307
349
  flows,
350
+ polls,
351
+ publishes,
352
+ routes,
308
353
  observations,
309
354
  duration_ms,
310
355
  seed,
@@ -358,26 +403,114 @@ fn parse_node(value: Value, i: usize) -> Res<Node> {
358
403
  };
359
404
  NodeKind::Switch { fifo, topology }
360
405
  }
361
- "mqtt_broker" | "modbus_slave" | "profinet_device" => {
362
- return Err(unsupported(&format!("{kind} nodes (Phase 5)")))
406
+ "modbus_slave" => {
407
+ f.string("ip")?;
408
+ let mac = f.string("mac")?;
409
+ let unit = f.integer("unit_id")?;
410
+ let unit =
411
+ u8::try_from(unit).map_err(|_| format!("modbus_slave {name}: unit_id {unit}"))?;
412
+ NodeKind::ModbusSlave { mac, unit }
413
+ }
414
+ "mqtt_broker" => {
415
+ f.string("ip")?;
416
+ NodeKind::MqttBroker {
417
+ mac: f.string("mac")?,
418
+ }
363
419
  }
420
+ "profinet_device" => return Err(unsupported(&format!("{kind} nodes (Phase 5)"))),
364
421
  other => return Err(format!("unknown node kind {other:?}")),
365
422
  };
366
423
  f.done()?;
367
424
  Ok(Node { name, kind })
368
425
  }
369
426
 
370
- fn parse_traffic(value: Value, i: usize) -> Res<Flow> {
427
+ enum Traffic {
428
+ Flow(Flow),
429
+ Poll(Poll),
430
+ Publish(Publish),
431
+ Route(Route),
432
+ }
433
+
434
+ fn parse_traffic(value: Value, i: usize) -> Res<Traffic> {
371
435
  let mut f = Fields::new(value, format!("traffic {i}"))?;
372
436
  let kind = f.string("kind")?;
373
- if kind != "flow" {
374
- return match kind.as_str() {
375
- "publish" | "route" | "poll" | "profinet_ar" => {
376
- Err(unsupported(&format!("{kind} traffic (Phase 5)")))
377
- }
378
- other => Err(format!("unknown traffic kind {other:?}")),
379
- };
437
+ match kind.as_str() {
438
+ "flow" => parse_flow(f).map(Traffic::Flow),
439
+ "poll" => {
440
+ let source = f.string("source")?;
441
+ let slave = f.string("slave")?;
442
+ f.what = format!("poll {source} -> {slave}");
443
+ f.integer("register")?; // the register address does not change the frames
444
+ let count = f.integer("count")?;
445
+ let count = u16::try_from(count).map_err(|_| format!("poll: count {count}"))?;
446
+ let rate = f.number("rate")?;
447
+ let delay_ms = match f.take_or("delay_ms") {
448
+ None => Q::int(0),
449
+ Some(v) => number(&v, "poll: delay_ms")?,
450
+ };
451
+ f.done()?;
452
+ Ok(Traffic::Poll(Poll {
453
+ source,
454
+ slave,
455
+ count,
456
+ rate,
457
+ delay_ms,
458
+ }))
459
+ }
460
+ "publish" => {
461
+ let source = f.string("source")?;
462
+ let broker = f.string("broker")?;
463
+ f.what = format!("publish {source} -> {broker}");
464
+ let topic = f.string("topic")?;
465
+ let rate = f.number("rate")?;
466
+ let payload = f.integer("payload")?;
467
+ let qos = f.integer("qos")?;
468
+ let qos = u8::try_from(qos)
469
+ .ok()
470
+ .filter(|q| *q <= 1)
471
+ .ok_or(format!("publish: qos {qos}"))?;
472
+ let delay_ms = match f.take_or("delay_ms") {
473
+ None => Q::int(0),
474
+ Some(v) => number(&v, "publish: delay_ms")?,
475
+ };
476
+ f.done()?;
477
+ Ok(Traffic::Publish(Publish {
478
+ source,
479
+ broker,
480
+ topic,
481
+ rate,
482
+ payload,
483
+ qos,
484
+ delay_ms,
485
+ }))
486
+ }
487
+ "route" => {
488
+ let broker = f.string("broker")?;
489
+ let topic = f.string("topic")?;
490
+ f.what = format!("route {broker} topic {topic:?}");
491
+ let subscribers = match f.take("subscribers")? {
492
+ Value::Array(items) => items
493
+ .into_iter()
494
+ .map(|v| match v {
495
+ Value::String(s) => Ok(s),
496
+ other => Err(format!("route: subscriber must be a name, got {other}")),
497
+ })
498
+ .collect::<Res<Vec<String>>>()?,
499
+ other => return Err(format!("route: subscribers must be a list, got {other}")),
500
+ };
501
+ f.done()?;
502
+ Ok(Traffic::Route(Route {
503
+ broker,
504
+ topic,
505
+ subscribers,
506
+ }))
507
+ }
508
+ "profinet_ar" => Err(unsupported(&format!("{kind} traffic (Phase 5)"))),
509
+ other => Err(format!("unknown traffic kind {other:?}")),
380
510
  }
511
+ }
512
+
513
+ fn parse_flow(mut f: Fields<'_>) -> Res<Flow> {
381
514
  let source = f.string("source")?;
382
515
  let destination = f.string("destination")?;
383
516
  f.what = format!("flow {source} -> {destination}");
@@ -477,6 +610,14 @@ mod tests {
477
610
  assert!(parse(&B1.replace("\"constant\"", "\"batch\""))
478
611
  .unwrap_err()
479
612
  .contains("needs a batch size"));
613
+ let mqtt = parse(&B1.replace(
614
+ "\"traffic\": [",
615
+ "\"traffic\": [{\"kind\": \"publish\", \"source\": \"tx\", \"broker\": \"rx\", \"topic\": \"hala/temp\\u00b0C\", \"rate\": 10, \"payload\": 20, \"qos\": 1, \"delay_ms\": 0.0}, {\"kind\": \"route\", \"broker\": \"rx\", \"topic\": \"t\", \"subscribers\": [\"tx\"]}, ",
616
+ ))
617
+ .unwrap();
618
+ assert_eq!(mqtt.publishes[0].topic, "hala/temp°C");
619
+ assert_eq!(mqtt.publishes[0].qos, 1);
620
+ assert_eq!(mqtt.routes[0].subscribers, ["tx"]);
480
621
  assert!(parse(&B1.replace("\"throughput\"", "\"pn_jitter\""))
481
622
  .unwrap_err()
482
623
  .contains("metric \"pn_jitter\""));