smolpy 1.8.2.dev6__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 (135) hide show
  1. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/PKG-INFO +2 -2
  2. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/README.md +1 -1
  3. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/dsl-reference.md +3 -3
  4. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/roadmap.md +5 -2
  5. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/src/frames.rs +14 -0
  6. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/src/scenario.rs +99 -11
  7. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/src/sim.rs +196 -51
  8. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/README.md +2 -1
  9. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/equivalence/scenarios.py +43 -0
  10. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/ci.yml +0 -0
  11. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/dev-build.yml +0 -0
  12. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/docs.yml +0 -0
  13. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/github-release.yml +0 -0
  14. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/publish.yml +0 -0
  15. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/release.yml +0 -0
  16. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.github/workflows/rust-wheels.yml +0 -0
  17. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/.gitignore +0 -0
  18. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/LICENSE +0 -0
  19. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/__init__.py +0 -0
  20. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/__main__.py +0 -0
  21. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  22. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  23. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  24. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  25. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  26. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  27. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  28. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/runner.py +0 -0
  29. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/scenarios.py +0 -0
  30. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/benchmarks/worker.py +0 -0
  31. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0001-protocol-package-structure.md +0 -0
  32. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  33. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0003-smol-external-dsl.md +0 -0
  34. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0004-execution-backends.md +0 -0
  35. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0005-profinet-rt.md +0 -0
  36. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  37. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  38. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  39. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +0 -0
  40. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  41. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/benchmarks.md +0 -0
  42. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/dashboard.md +0 -0
  43. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/examples.md +0 -0
  44. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/index.md +0 -0
  45. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/language-reference.md +0 -0
  46. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/modbus.md +0 -0
  47. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/model-semantics.md +0 -0
  48. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/mqtt.md +0 -0
  49. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/profinet.md +0 -0
  50. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/scenario-model.md +0 -0
  51. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/docs/simulation-engine.md +0 -0
  52. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/README.md +0 -0
  53. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example.py +0 -0
  54. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example.smol +0 -0
  55. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_10_clients.py +0 -0
  56. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_12_clients.py +0 -0
  57. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_20_clients.py +0 -0
  58. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_file_transfer.py +0 -0
  59. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_modbus.py +0 -0
  60. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_mqtt.py +0 -0
  61. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_profinet.py +0 -0
  62. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_profinet.smol +0 -0
  63. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_staggered_transfer.py +0 -0
  64. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/examples/example_two_tier.py +0 -0
  65. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/mkdocs.yml +0 -0
  66. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/pyproject.toml +0 -0
  67. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/Cargo.lock +0 -0
  68. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/Cargo.toml +0 -0
  69. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/Cargo.toml +0 -0
  70. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/src/lib.rs +0 -0
  71. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/src/rng.rs +0 -0
  72. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smol-engine/src/timebase.rs +0 -0
  73. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  74. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  75. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  76. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  77. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/__init__.py +0 -0
  78. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/_worker.py +0 -0
  79. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/backends.py +0 -0
  80. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/batch.py +0 -0
  81. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/cli.py +0 -0
  82. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/__init__.py +0 -0
  83. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/adapter.py +0 -0
  84. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/batch.py +0 -0
  85. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/link.py +0 -0
  86. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/network.py +0 -0
  87. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/node.py +0 -0
  88. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/core/observation.py +0 -0
  89. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/ethernet/__init__.py +0 -0
  90. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/ethernet/switch.py +0 -0
  91. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/lang/__init__.py +0 -0
  92. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/lang/ast.py +0 -0
  93. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/lang/errors.py +0 -0
  94. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/lang/grammar.lark +0 -0
  95. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/lang/interpreter.py +0 -0
  96. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/lang/transformer.py +0 -0
  97. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/modbus/__init__.py +0 -0
  98. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/modbus/slave.py +0 -0
  99. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/model/__init__.py +0 -0
  100. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/model/frames.py +0 -0
  101. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/model/scenario.py +0 -0
  102. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/model/streams.py +0 -0
  103. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/model/timebase.py +0 -0
  104. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/model/validate.py +0 -0
  105. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/mqtt/__init__.py +0 -0
  106. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/mqtt/broker.py +0 -0
  107. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/profinet/__init__.py +0 -0
  108. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/profinet/device.py +0 -0
  109. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/sim/__init__.py +0 -0
  110. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/sim/engine.py +0 -0
  111. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/stats.py +0 -0
  112. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/viz/__init__.py +0 -0
  113. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/viz/dashboard.py +0 -0
  114. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/src/smolpy/viz/text_dashboard.py +0 -0
  115. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/__init__.py +0 -0
  116. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/equivalence/__init__.py +0 -0
  117. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/equivalence/harness.py +0 -0
  118. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/equivalence/test_equivalence.py +0 -0
  119. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/equivalence/test_rust_timebase.py +0 -0
  120. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_backends.py +0 -0
  121. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_batch.py +0 -0
  122. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_benchmarks.py +0 -0
  123. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_cli.py +0 -0
  124. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_dsl.py +0 -0
  125. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_engine_ir.py +0 -0
  126. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_lang.py +0 -0
  127. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_model.py +0 -0
  128. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_profinet.py +0 -0
  129. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_semantics.py +0 -0
  130. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_simulation.py +0 -0
  131. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_stats.py +0 -0
  132. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_sweep.py +0 -0
  133. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_timebase.py +0 -0
  134. {smolpy-1.8.2.dev6 → smolpy-1.8.2.dev8}/tests/test_validate.py +0 -0
  135. {smolpy-1.8.2.dev6 → 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.dev6
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
@@ -48,7 +48,7 @@ SMOLPy lets you describe a network topology in pure Python, define traffic flows
48
48
  > result = net.simulate(duration=60_000, backend="rust")
49
49
  > ```
50
50
  >
51
- > The Rust engine covers Ethernet and Modbus TCP for now: adapters, switches, links, flows and Modbus polling. MQTT 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/).
52
52
 
53
53
  📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
54
54
 
@@ -20,7 +20,7 @@ SMOLPy lets you describe a network topology in pure Python, define traffic flows
20
20
  > result = net.simulate(duration=60_000, backend="rust")
21
21
  > ```
22
22
  >
23
- > The Rust engine covers Ethernet and Modbus TCP for now: adapters, switches, links, flows and Modbus polling. MQTT 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/).
24
24
 
25
25
  📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
26
26
 
@@ -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 also runs Modbus TCP: slaves, `polls()` and `modbus_latency`. It covers the metrics `throughput`, `latency`, `bytes_sent`, `bytes_received`, `queue_depth`, `utilization` and `modbus_latency`.
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 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,11 +153,14 @@ 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:** one of three protocols done.
156
+ **Status:** two of three protocols done.
157
157
  - **Modbus TCP: done.**
158
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
159
  - The new `polling` scenario is bit-exact with SimPy, down to the event count.
160
- - **MQTT and PROFINET RT** are next. PROFINET's watchdog waits on "a frame or a timeout", a SimPy condition whose event ordering the engine has to reproduce.
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.
161
164
 
162
165
  ## Phase 6: ns-3 high-fidelity backend ([ADR-0004](adr/0004-execution-backends.md), revised)
163
166
 
@@ -21,6 +21,16 @@ pub fn padded(bytes: u64) -> u64 {
21
21
  bytes.max(MIN_FRAME_BYTES)
22
22
  }
23
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
+
24
34
  /// Read Holding Registers response: MBAP (6), FC (1), byte count (1), 2 B per register.
25
35
  pub fn modbus_response_frame_size(count: u16) -> u64 {
26
36
  padded(ETHERNET_IP_TCP_BYTES + 6 + 1 + 1 + 2 * count as u64)
@@ -45,5 +55,9 @@ mod tests {
45
55
  assert_eq!(MODBUS_REQUEST_BYTES, 69);
46
56
  assert_eq!(modbus_response_frame_size(10), 86);
47
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);
48
62
  }
49
63
  }
@@ -16,6 +16,7 @@ pub const VERSION: u64 = 2;
16
16
  pub enum NodeKind {
17
17
  Adapter { mac: String },
18
18
  ModbusSlave { mac: String, unit: u8 },
19
+ MqttBroker { mac: String },
19
20
  Switch { fifo: bool, topology: bool },
20
21
  }
21
22
 
@@ -69,6 +70,26 @@ pub struct Poll {
69
70
  pub delay_ms: Q,
70
71
  }
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
+
72
93
  #[derive(Debug, Clone, Copy, PartialEq, Eq)]
73
94
  pub enum Metric {
74
95
  Throughput,
@@ -78,10 +99,11 @@ pub enum Metric {
78
99
  QueueDepth,
79
100
  Utilization,
80
101
  ModbusLatency,
102
+ BrokerQueue,
81
103
  }
82
104
 
83
105
  impl Metric {
84
- pub const ALL: [(&'static str, Metric); 7] = [
106
+ pub const ALL: [(&'static str, Metric); 8] = [
85
107
  ("throughput", Metric::Throughput),
86
108
  ("latency", Metric::Latency),
87
109
  ("bytes_sent", Metric::BytesSent),
@@ -89,6 +111,7 @@ impl Metric {
89
111
  ("queue_depth", Metric::QueueDepth),
90
112
  ("utilization", Metric::Utilization),
91
113
  ("modbus_latency", Metric::ModbusLatency),
114
+ ("broker_queue", Metric::BrokerQueue),
92
115
  ];
93
116
 
94
117
  pub fn name(self) -> &'static str {
@@ -110,6 +133,8 @@ pub struct Scenario {
110
133
  pub links: Vec<Link>,
111
134
  pub flows: Vec<Flow>,
112
135
  pub polls: Vec<Poll>,
136
+ pub publishes: Vec<Publish>,
137
+ pub routes: Vec<Route>,
113
138
  pub observations: Vec<Observation>,
114
139
  pub duration_ms: Q,
115
140
  pub seed: u64,
@@ -126,8 +151,8 @@ pub struct Capabilities {
126
151
  }
127
152
 
128
153
  pub const CAPABILITIES: Capabilities = Capabilities {
129
- nodes: &["adapter", "switch", "modbus_slave"],
130
- traffic: &["flow", "poll"],
154
+ nodes: &["adapter", "switch", "modbus_slave", "mqtt_broker"],
155
+ traffic: &["flow", "poll", "publish", "route"],
131
156
  patterns: &["constant", "poisson", "bursty", "batch"],
132
157
  metrics: &[
133
158
  "throughput",
@@ -137,13 +162,11 @@ pub const CAPABILITIES: Capabilities = Capabilities {
137
162
  "queue_depth",
138
163
  "utilization",
139
164
  "modbus_latency",
165
+ "broker_queue",
140
166
  ],
141
167
  features: &["imix"],
142
168
  notes: &[
143
- ("mqtt_broker", "planned for Phase 5"),
144
169
  ("profinet_device", "planned for Phase 5"),
145
- ("publish", "planned for Phase 5"),
146
- ("route", "planned for Phase 5"),
147
170
  ("profinet_ar", "planned for Phase 5"),
148
171
  ],
149
172
  };
@@ -269,7 +292,8 @@ pub fn parse(text: &str) -> Res<Scenario> {
269
292
  f.done()?;
270
293
  links.push(link);
271
294
  }
272
- let (mut flows, mut polls) = (Vec::new(), Vec::new());
295
+ let (mut flows, mut polls, mut publishes, mut routes) =
296
+ (Vec::new(), Vec::new(), Vec::new(), Vec::new());
273
297
  for (i, v) in array(top.take_or("traffic"), "traffic")?
274
298
  .into_iter()
275
299
  .enumerate()
@@ -277,6 +301,8 @@ pub fn parse(text: &str) -> Res<Scenario> {
277
301
  match parse_traffic(v, i)? {
278
302
  Traffic::Flow(flow) => flows.push(flow),
279
303
  Traffic::Poll(poll) => polls.push(poll),
304
+ Traffic::Publish(publish) => publishes.push(publish),
305
+ Traffic::Route(route) => routes.push(route),
280
306
  }
281
307
  }
282
308
  let mut observations = Vec::new();
@@ -322,6 +348,8 @@ pub fn parse(text: &str) -> Res<Scenario> {
322
348
  links,
323
349
  flows,
324
350
  polls,
351
+ publishes,
352
+ routes,
325
353
  observations,
326
354
  duration_ms,
327
355
  seed,
@@ -383,9 +411,13 @@ fn parse_node(value: Value, i: usize) -> Res<Node> {
383
411
  u8::try_from(unit).map_err(|_| format!("modbus_slave {name}: unit_id {unit}"))?;
384
412
  NodeKind::ModbusSlave { mac, unit }
385
413
  }
386
- "mqtt_broker" | "profinet_device" => {
387
- return Err(unsupported(&format!("{kind} nodes (Phase 5)")))
414
+ "mqtt_broker" => {
415
+ f.string("ip")?;
416
+ NodeKind::MqttBroker {
417
+ mac: f.string("mac")?,
418
+ }
388
419
  }
420
+ "profinet_device" => return Err(unsupported(&format!("{kind} nodes (Phase 5)"))),
389
421
  other => return Err(format!("unknown node kind {other:?}")),
390
422
  };
391
423
  f.done()?;
@@ -395,6 +427,8 @@ fn parse_node(value: Value, i: usize) -> Res<Node> {
395
427
  enum Traffic {
396
428
  Flow(Flow),
397
429
  Poll(Poll),
430
+ Publish(Publish),
431
+ Route(Route),
398
432
  }
399
433
 
400
434
  fn parse_traffic(value: Value, i: usize) -> Res<Traffic> {
@@ -423,9 +457,55 @@ fn parse_traffic(value: Value, i: usize) -> Res<Traffic> {
423
457
  delay_ms,
424
458
  }))
425
459
  }
426
- "publish" | "route" | "profinet_ar" => {
427
- Err(unsupported(&format!("{kind} traffic (Phase 5)")))
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
+ }))
428
507
  }
508
+ "profinet_ar" => Err(unsupported(&format!("{kind} traffic (Phase 5)"))),
429
509
  other => Err(format!("unknown traffic kind {other:?}")),
430
510
  }
431
511
  }
@@ -530,6 +610,14 @@ mod tests {
530
610
  assert!(parse(&B1.replace("\"constant\"", "\"batch\""))
531
611
  .unwrap_err()
532
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"]);
533
621
  assert!(parse(&B1.replace("\"throughput\"", "\"pn_jitter\""))
534
622
  .unwrap_err()
535
623
  .contains("metric \"pn_jitter\""));