smolpy 1.11.1.dev2__tar.gz → 1.11.1.dev5__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 (158) hide show
  1. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/PKG-INFO +2 -2
  2. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0012-modbus-one-request-in-flight.md +1 -1
  3. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/model-semantics.md +23 -10
  4. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/scenario-model.md +1 -1
  5. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/pyproject.toml +5 -5
  6. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/src/scenario.rs +44 -16
  7. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/src/sim.rs +146 -13
  8. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smolpy-engine-rs/README.md +1 -1
  9. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/backends.py +1 -1
  10. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/network.py +2 -0
  11. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/observation.py +2 -0
  12. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/model/validate.py +5 -0
  13. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/sim/engine.py +92 -4
  14. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/viz/dashboard.py +2 -0
  15. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/viz/text_dashboard.py +2 -0
  16. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/equivalence/scenarios.py +53 -0
  17. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_ns3.py +3 -1
  18. smolpy-1.11.1.dev5/tests/test_outstanding.py +497 -0
  19. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/uv.lock +8 -8
  20. smolpy-1.11.1.dev2/tests/test_outstanding.py +0 -210
  21. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/ci.yml +0 -0
  22. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/dev-build.yml +0 -0
  23. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/docker-image.yml +0 -0
  24. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/docs.yml +0 -0
  25. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/github-release.yml +0 -0
  26. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/ns3-base.yml +0 -0
  27. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/publish.yml +0 -0
  28. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/release.yml +0 -0
  29. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.github/workflows/rust-wheels.yml +0 -0
  30. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/.gitignore +0 -0
  31. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/LICENSE +0 -0
  32. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/README.md +0 -0
  33. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/__init__.py +0 -0
  34. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/__main__.py +0 -0
  35. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/load.py +0 -0
  36. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/loss.py +0 -0
  37. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  38. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  39. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  40. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  41. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  42. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  43. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  44. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-16-1839-simpy-ns3-jaws-zbook-tcp-under-load.json +0 -0
  45. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/results/2026-11-23-1228-simpy-rust-ns3-jaws-zbook-bounded-buffers.json +0 -0
  46. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/runner.py +0 -0
  47. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/scenarios.py +0 -0
  48. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/benchmarks/worker.py +0 -0
  49. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/Dockerfile +0 -0
  50. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/Dockerfile.dockerignore +0 -0
  51. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/Dockerfile.ns3 +0 -0
  52. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/Dockerfile.ns3.dockerignore +0 -0
  53. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/ns3-base/Dockerfile +0 -0
  54. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/ns3-base/smoke.cc +0 -0
  55. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docker/smoke.smol +0 -0
  56. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0001-protocol-package-structure.md +0 -0
  57. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  58. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0003-smol-external-dsl.md +0 -0
  59. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0004-execution-backends.md +0 -0
  60. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0005-profinet-rt.md +0 -0
  61. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  62. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  63. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  64. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +0 -0
  65. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  66. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/adr/0011-bounded-switch-buffers.md +0 -0
  67. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/backends.md +0 -0
  68. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/benchmarks.md +0 -0
  69. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/dashboard.md +0 -0
  70. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/dsl-reference.md +0 -0
  71. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/examples.md +0 -0
  72. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/index.md +0 -0
  73. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/language-reference.md +0 -0
  74. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/modbus.md +0 -0
  75. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/mqtt.md +0 -0
  76. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/profinet.md +0 -0
  77. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/roadmap.md +0 -0
  78. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/docs/simulation-engine.md +0 -0
  79. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/README.md +0 -0
  80. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example.py +0 -0
  81. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example.smol +0 -0
  82. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_10_clients.py +0 -0
  83. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_12_clients.py +0 -0
  84. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_20_clients.py +0 -0
  85. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_bounded_buffer.smol +0 -0
  86. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_file_transfer.py +0 -0
  87. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_modbus.py +0 -0
  88. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_mqtt.py +0 -0
  89. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_profinet.py +0 -0
  90. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_profinet.smol +0 -0
  91. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_staggered_transfer.py +0 -0
  92. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/examples/example_two_tier.py +0 -0
  93. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/mkdocs.yml +0 -0
  94. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/Cargo.lock +0 -0
  95. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/Cargo.toml +0 -0
  96. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/Cargo.toml +0 -0
  97. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/src/frames.rs +0 -0
  98. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/src/lib.rs +0 -0
  99. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/src/rng.rs +0 -0
  100. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smol-engine/src/timebase.rs +0 -0
  101. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  102. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  103. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  104. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  105. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/__init__.py +0 -0
  106. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/_worker.py +0 -0
  107. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/batch.py +0 -0
  108. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/cli.py +0 -0
  109. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/__init__.py +0 -0
  110. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/adapter.py +0 -0
  111. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/batch.py +0 -0
  112. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/link.py +0 -0
  113. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/core/node.py +0 -0
  114. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/ethernet/__init__.py +0 -0
  115. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/ethernet/switch.py +0 -0
  116. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/lang/__init__.py +0 -0
  117. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/lang/ast.py +0 -0
  118. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/lang/errors.py +0 -0
  119. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/lang/grammar.lark +0 -0
  120. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/lang/interpreter.py +0 -0
  121. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/lang/transformer.py +0 -0
  122. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/modbus/__init__.py +0 -0
  123. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/modbus/slave.py +0 -0
  124. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/model/__init__.py +0 -0
  125. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/model/frames.py +0 -0
  126. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/model/scenario.py +0 -0
  127. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/model/streams.py +0 -0
  128. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/model/timebase.py +0 -0
  129. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/mqtt/__init__.py +0 -0
  130. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/mqtt/broker.py +0 -0
  131. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/ns3/__init__.py +0 -0
  132. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/ns3/cpp/smol-ns3.cc +0 -0
  133. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/profinet/__init__.py +0 -0
  134. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/profinet/device.py +0 -0
  135. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/sim/__init__.py +0 -0
  136. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/stats.py +0 -0
  137. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/src/smolpy/viz/__init__.py +0 -0
  138. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/__init__.py +0 -0
  139. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/equivalence/__init__.py +0 -0
  140. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/equivalence/harness.py +0 -0
  141. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/equivalence/test_equivalence.py +0 -0
  142. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/equivalence/test_rust_timebase.py +0 -0
  143. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_backends.py +0 -0
  144. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_batch.py +0 -0
  145. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_benchmarks.py +0 -0
  146. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_buffers.py +0 -0
  147. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_cli.py +0 -0
  148. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_dsl.py +0 -0
  149. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_engine_ir.py +0 -0
  150. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_lang.py +0 -0
  151. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_model.py +0 -0
  152. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_profinet.py +0 -0
  153. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_semantics.py +0 -0
  154. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_simulation.py +0 -0
  155. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_stats.py +0 -0
  156. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_sweep.py +0 -0
  157. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_timebase.py +0 -0
  158. {smolpy-1.11.1.dev2 → smolpy-1.11.1.dev5}/tests/test_validate.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: smolpy
3
- Version: 1.11.1.dev2
3
+ Version: 1.11.1.dev5
4
4
  Summary: Network simulation DSL and discrete-event simulator
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -23,7 +23,7 @@ Requires-Dist: ruff; extra == 'dev'
23
23
  Provides-Extra: docs
24
24
  Requires-Dist: mkdocs-material>=9; extra == 'docs'
25
25
  Provides-Extra: rust
26
- Requires-Dist: smolpy-engine-rs>=1.10.3.dev0; extra == 'rust'
26
+ Requires-Dist: smolpy-engine-rs>=1.11.1.dev0; extra == 'rust'
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  # SMOLPy
@@ -76,7 +76,7 @@ laptop.polls(server, register=0, count=10, rate=100, outstanding=1, timeout_ms=5
76
76
  - **Without `timeout`, the master waits forever.** On SimPy and Rust a single lost request or response then stops that pair's polling for the rest of the run. That is what a master without a timeout would do without TCP retransmission, and `modbus_skipped` shows it. Documentation recommends a timeout on those backends.
77
77
  - **Validation:**
78
78
  - `outstanding` is `1` or unset. The IR holds an integer, so that a window of `N` can be added later.
79
- - `timeout` is a positive number, at least 1 ns after rounding (§1), and set only with `outstanding=1`.
79
+ - `timeout` is a positive number, at least 1 ns after rounding (§1) and at most 2^63 − 1 ns, as a duration, and set only with `outstanding=1`.
80
80
  - **A pair with `outstanding=1` has one poll statement.** Two statements to the same slave would have to share one transaction slot, and their instants would compete. The rule needed for that, a transaction queue per connection, is left for later. Several register blocks of one slave are one poll with a larger `count`.
81
81
  - **IR.** `Poll.outstanding: int | None = None` and `Poll.timeout_ms: float | None = None`.
82
82
 
@@ -128,19 +128,19 @@ On the wire it is preceded by a preamble and SFD and followed by an inter-frame
128
128
  |---|---|
129
129
  | Adapter | counts it for its metrics (any frame kind); PROFINET frames also go to its PROFINET consumer |
130
130
  | MQTT broker | for a PUBLISH: one copy to every subscriber of its topic, in subscriber order, then a PUBACK to the publisher if `qos = 1`. A topic without a route is not forwarded. Other frames are ignored. |
131
- | Modbus slave | for a request with its `unit_id`: one response to the requester |
131
+ | Modbus slave | for a request with its `unit_id`: one response to the requester, with the request's MBAP transaction id |
132
132
  | PROFINET device | passes cyclic frames of its ARs to its PROFINET consumer |
133
133
 
134
134
  An end station sends everything over its single link, in the egress queue order of [§3](#3-links-and-egress-queues). Its egress queue is unbounded.
135
135
 
136
136
  **When a frame is lost** at a bounded switch, nothing is retransmitted: the model has no transport layer ([ADR-0011](adr/0011-bounded-switch-buffers.md)).
137
- - **Modbus:** a lost request or response leaves its poll without a response. The master does not retry, and its next polls go out on schedule.
137
+ - **Modbus:** a lost request or response leaves its poll without a response, and the master does not retry. An open-loop poll sends its next requests on schedule. A poll with `outstanding=1` waits for its timeout ([§6](#6-traffic-sources)), or forever without one.
138
138
  - **MQTT:** a lost PUBLISH is neither forwarded nor acknowledged. A lost copy is lost to its subscriber. A lost PUBACK changes nothing.
139
139
  - **PROFINET RT:** a lost cyclic frame leaves a gap, and the watchdog expires if it exceeds `hold × cycle` ([§7](#7-profinet-consumer)).
140
140
 
141
141
  The ns-3 backend runs Modbus and MQTT over ns-3's TCP, which retransmits lost segments ([Execution backends](backends.md)).
142
142
 
143
- *Tests: `test_a_lost_poll_stays_unanswered`, `test_a_lost_profinet_frame_expires_the_watchdog` in `test_buffers.py`.*
143
+ *Tests: `test_a_lost_poll_stays_unanswered`, `test_a_lost_profinet_frame_expires_the_watchdog` in `test_buffers.py`; `test_without_a_timeout_a_lost_response_stops_the_pair` in `test_outstanding.py`.*
144
144
 
145
145
  ## 6. Traffic sources
146
146
 
@@ -158,10 +158,19 @@ The ns-3 backend runs Modbus and MQTT over ns-3's TCP, which retransmits lost se
158
158
  | `Flow`, `batch` | groups at Poisson instants with mean gap `T · E[X]`. Each group is X frames queued at the same instant, X drawn per group from the batch distribution. The long-run rate is `rate`. |
159
159
  | `Flow`, `bursty` | repeated ON/OFF cycles: L = max(1, ⌊Pareto(1.5)⌋) frames spaced `T/4` (the first one `T/4` after the cycle starts), then a silence of `T · L · U(0.3, 1.2)`. A cycle lasts `T · L` on average, so the long-run rate is `rate`. Frame *j* of a cycle is at `round(j · T/4)` after the cycle starts, and the silence is rounded to ns. |
160
160
  | `Publish` | one PUBLISH at `delay + T`, `delay + 2T`, … |
161
- | `Poll` | one request at `delay + T`, `delay + 2T`, … |
161
+ | `Poll` | one request at `delay + T`, `delay + 2T`, …; with `outstanding=1`, only at the instants when the pair is free (below) |
162
162
  | `ProfinetAR` | the controller sends an output frame, and the device an input frame, at `delay`, `delay + cycle`, `delay + 2·cycle`, … Note that the first frame goes out at `delay`, not one cycle later. |
163
163
 
164
- *Tests: `test_constant_flow_first_frame_after_one_interval`, `test_profinet_first_frame_at_delay`, `test_bursty_long_run_rate`, `test_source_ids`, `test_stream_seed_is_a_sha256_prefix`, `test_adding_a_source_does_not_change_the_others`, `test_run_seed_selects_the_draws`.*
164
+ **One request in flight** ([ADR-0012](adr/0012-modbus-one-request-in-flight.md)). A poll with `outstanding=1` keeps at most one request of its master–slave pair **outstanding**: sent, and neither answered nor timed out.
165
+ - **Poll instants.** At each instant of its schedule, the request is sent if no request is outstanding and the previous one did not complete at that same instant. Otherwise the instant is **skipped** and counted. The schedule itself does not change, so it does not drift.
166
+ - **Transaction ids.** The requests of a pair carry consecutive MBAP transaction ids from 0, and a response carries its request's id.
167
+ - **A response is accepted** if it carries the outstanding id and arrives at `a < s + τ`, where `s` is when the request was sent and `τ` the timeout, rounded to ns. It completes the transaction at `a`.
168
+ - **A timeout** fires at `s + τ` if the request is still outstanding: it counts as timed out and completes the transaction at `s + τ`.
169
+ - **Any other response is late and discarded:** it has a stale id or arrived at or after `s + τ`. Like every frame, it counts as accepted by the NIC (`frames_received`, `bytes_received`, `throughput`, `latency`). It is not a response for `modbus_latency` or `modbus_unanswered`.
170
+ - **Without `timeout`** an outstanding request is waited for forever.
171
+ - **One poll per pair.** A pair with `outstanding=1` has one poll statement (validation).
172
+
173
+ *Tests: `test_constant_flow_first_frame_after_one_interval`, `test_profinet_first_frame_at_delay`, `test_bursty_long_run_rate`, `test_source_ids`, `test_stream_seed_is_a_sha256_prefix`, `test_adding_a_source_does_not_change_the_others`, `test_run_seed_selects_the_draws`; one request in flight in `test_outstanding.py`: `test_an_instant_is_skipped_while_a_request_is_outstanding`, `test_a_timeout_fires_exactly_after_its_time`, `test_a_response_at_the_timeout_is_late`, `test_without_loss_and_under_the_period_nothing_changes`.*
165
174
 
166
175
  ## 7. PROFINET consumer
167
176
 
@@ -188,7 +197,7 @@ The ns-3 backend runs Modbus and MQTT over ns-3's TCP, which retransmits lost se
188
197
  | `latency` | mean of (arrival − origin time) over frames the adapter accepted in the window, of any kind. *Window metric.* | µs |
189
198
  | `bytes_received` | total frame bytes the adapter accepted so far / 10⁶ | MB |
190
199
  | `bytes_sent` | total frame bytes whose transmission on the adapter's link has completed so far / 10⁶ | MB |
191
- | `modbus_latency` | mean of (arrival − origin time) over Modbus responses the adapter accepted in the window: the round-trip time from generating the request. *Window metric.* | µs |
200
+ | `modbus_latency` | mean of (arrival − origin time) over Modbus responses the adapter accepted in the window: the round-trip time from sending the request. A late response is not counted ([§6](#6-traffic-sources)). *Window metric.* | µs |
192
201
  | `queue_depth` | frames waiting in all egress queues of the switch, not counting frames being transmitted | frames |
193
202
  | `utilization` | wire bits, frame + 20 B per frame, of the frames whose transmission completed on the links *into* the node in the window, as a share of those links' combined capacity over the window. A saturated link shows 100 %. | % |
194
203
  | `broker_queue` | frames delivered to the broker and not yet processed. The broker has no service time, so this is non-zero only for frames arriving at the sample instant itself. | frames |
@@ -199,7 +208,9 @@ The ns-3 backend runs Modbus and MQTT over ns-3's TCP, which retransmits lost se
199
208
  | `drops_total` | frames the switch's egress buffers dropped so far | frames |
200
209
  | `frames_sent` | frames whose transmission on the adapter's link has completed so far | frames |
201
210
  | `frames_received` | frames the adapter accepted so far | frames |
202
- | `modbus_unanswered` | Modbus requests the adapter's polls have generated so far, less the responses it has accepted so far: lost polls plus polls in flight | polls |
211
+ | `modbus_unanswered` | Modbus requests the adapter's polls have sent so far, less the responses it has accepted so far: lost polls plus polls in flight. With `outstanding=1`, requests that timed out plus those outstanding. | polls |
212
+ | `modbus_timeouts` | requests of the adapter's polls that have timed out so far | polls |
213
+ | `modbus_skipped` | poll instants the adapter's polls have skipped so far, because a request was outstanding | polls |
203
214
 
204
215
  A metric's result key is `"<metric>:<node>"`. Its samples are `(time_ms, value)` pairs in time order.
205
216
 
@@ -212,20 +223,22 @@ A metric's result key is `"<metric>:<node>"`. Its samples are `(time_ms, value)`
212
223
  - **`utilization`:** `wire_bits × 10⁵ / (Σ speed × W)` %, where `speed` is in Mb/s.
213
224
 
214
225
  **Frame bytes, not wire bytes.** The byte metrics count frames, header to FCS, without the preamble, SFD and gap, as switch and NIC counters do. So a saturated 100 Mb/s link carrying 64 B frames shows 76.2 Mb/s of `throughput` and 100 % `utilization`.
215
- - **Counts** (`queue_depth`, `broker_queue`, `pn_watchdog_expiries`, `drops`, `drops_total`, `frames_sent`, `frames_received`, `modbus_unanswered`) as they are.
226
+ - **Counts** (`queue_depth`, `broker_queue`, `pn_watchdog_expiries`, `drops`, `drops_total`, `frames_sent`, `frames_received`, `modbus_unanswered`, `modbus_timeouts`, `modbus_skipped`) as they are.
227
+ - **Polls with one request in flight.** For an adapter whose polls all have `outstanding=1`, `modbus_unanswered` is `modbus_timeouts` plus its pairs with a request outstanding, and its poll instants so far are its requests sent plus `modbus_skipped`.
216
228
  - **Loss of a flow** `a → b`, when `a` sends nothing else: `frames_sent:a − frames_received:b` is the frames dropped plus the frames in flight, which are at most the buffers on the path and a frame per link.
217
229
 
218
- *Tests: `test_metric_definitions`, `test_window_metrics_skip_empty_windows`, `test_modbus_latency_is_round_trip`, `test_mqtt_latency_is_end_to_end`, `test_watchdog_expiries_are_cumulative`; `test_loss_is_frames_sent_less_frames_received` in `test_buffers.py`.*
230
+ *Tests: `test_metric_definitions`, `test_window_metrics_skip_empty_windows`, `test_modbus_latency_is_round_trip`, `test_mqtt_latency_is_end_to_end`, `test_watchdog_expiries_are_cumulative`; `test_loss_is_frames_sent_less_frames_received` in `test_buffers.py`; `test_the_counts_are_consistent` in `test_outstanding.py`.*
219
231
 
220
232
  ## 9. Simultaneous events
221
233
 
222
- **Events at the same simulated instant are processed in the order they were scheduled** (first in, first out). Two cases are observable:
234
+ **Events at the same simulated instant are processed in the order they were scheduled** (first in, first out). These cases are observable:
223
235
 
224
236
  - **A frame arriving at exactly a sample instant** belongs to the window that ends there if its arrival was scheduled before the sample, and to the next window otherwise.
225
237
  - **Frames queued at the same instant on one egress queue** are served by priority, then in the order they were queued:
226
238
  - a batch group in draw order;
227
239
  - broker copies in subscriber order, then the PUBACK.
228
240
  - This holds on an idle port too: its transmitter takes a frame after the events already scheduled for the instant, so it takes the highest-priority frame queued by then.
241
+ - **A poll with one request in flight** at the instant its previous request completes, by a response or a timeout, skips that instant, whichever event comes first. A response arriving at exactly its timeout is late, whichever comes first ([§6](#6-traffic-sources)). Neither rule depends on the order of events.
229
242
  - **Admissions to a bounded queue** at the same instant are decided in the order the frames are queued, each against the bytes queued at that moment ([§3](#3-links-and-egress-queues)). A frame the transmitter has taken no longer counts.
230
243
 
231
244
  **Start-up order** decides the scheduling order of the first events:
@@ -77,7 +77,7 @@ link c -- sw: 'sw' has only 2 ports, all in use
77
77
  | `Flow` | source and destination are adapters; `rate` > 0; `size` ≥ 1 or `imix`; known `pattern`; `priority` 0–7; a batch size exactly when `pattern="batch"` |
78
78
  | `Publish` | adapter → MQTT broker; non-empty topic; `rate` > 0; `qos` 0 or 1 (QoS 2 is not modelled) |
79
79
  | `Route` | broker → adapters, each subscriber once |
80
- | `Poll` | adapter → Modbus slave; `register` 0–65535; `count` 1–125; `rate` > 0; `outstanding` 1 or unset; `timeout_ms` ≥ 1 ns, only with `outstanding`; with `outstanding`, one poll per master–slave pair |
80
+ | `Poll` | adapter → Modbus slave; `register` 0–65535; `count` 1–125; `rate` > 0; `outstanding` 1 or unset; `timeout_ms` from 1 ns to 2^63 − 1 ns, only with `outstanding`; with `outstanding`, one poll per master–slave pair |
81
81
  | `ProfinetAR` | adapter → PROFINET device; `cycle` 1, 2, 4 … 512 ms; `inputs`/`outputs` 1–1440 B; `hold` 1–255 |
82
82
  | observations | an implemented metric (`frame_loss` is not); a node type the metric applies to; `every` > 0 |
83
83
  | run | `duration` > 0; integer `seed` |
@@ -29,11 +29,11 @@ dev = ["pytest>=8", "ruff", "mypy"]
29
29
  docs = ["mkdocs-material>=9"]
30
30
  # The native Rust engine (ADR-0008), released together with smolpy and with
31
31
  # the same version. At import smolpy checks the IR version the module reads,
32
- # and each run checks its capabilities. Bounded switch buffers (ADR-0011)
33
- # come with the release after 1.10.2: the floor admits it and the development
34
- # builds that lead to it. The earliest of those predate the buffers, and a run
35
- # that needs them is refused there by the engine's capabilities.
36
- rust = ["smolpy-engine-rs>=1.10.3.dev0"]
32
+ # and each run checks its capabilities. Polls with one request in flight
33
+ # (ADR-0012) come with the release after 1.11.0: the floor admits it and the
34
+ # development builds that lead to it. The earliest of those predate them, and
35
+ # a run that needs them is refused there by the engine's capabilities.
36
+ rust = ["smolpy-engine-rs>=1.11.1.dev0"]
37
37
 
38
38
  [build-system]
39
39
  requires = ["hatchling", "hatch-vcs"]
@@ -1,6 +1,6 @@
1
1
  //! Reads Scenario IR JSON, format "smol-ir" version 2 (ADR-0007, ADR-0010),
2
- //! with the optional switch buffers of ADR-0011. Polls with one request in
3
- //! flight (ADR-0012) are rejected.
2
+ //! with the optional switch buffers of ADR-0011 and the optional
3
+ //! `outstanding` and `timeout_ms` of polls (ADR-0012).
4
4
  //!
5
5
  //! The scenario has already been validated by `smolpy.model.validate`; this
6
6
  //! reader is strict about structure (unknown fields, kinds and versions are
@@ -85,6 +85,10 @@ pub struct Poll {
85
85
  pub count: u16,
86
86
  pub rate: Q,
87
87
  pub delay_ms: Q,
88
+ /// one request in flight (`outstanding=1`), or open loop (ADR-0012)
89
+ pub one_in_flight: bool,
90
+ /// the master's response timeout, with one request in flight
91
+ pub timeout_ms: Option<Q>,
88
92
  }
89
93
 
90
94
  /// MQTT PUBLISH messages to a broker at `rate` messages per second.
@@ -139,10 +143,12 @@ pub enum Metric {
139
143
  FramesSent,
140
144
  FramesReceived,
141
145
  ModbusUnanswered,
146
+ ModbusTimeouts,
147
+ ModbusSkipped,
142
148
  }
143
149
 
144
150
  impl Metric {
145
- pub const ALL: [(&'static str, Metric); 16] = [
151
+ pub const ALL: [(&'static str, Metric); 18] = [
146
152
  ("throughput", Metric::Throughput),
147
153
  ("latency", Metric::Latency),
148
154
  ("bytes_sent", Metric::BytesSent),
@@ -159,6 +165,8 @@ impl Metric {
159
165
  ("frames_sent", Metric::FramesSent),
160
166
  ("frames_received", Metric::FramesReceived),
161
167
  ("modbus_unanswered", Metric::ModbusUnanswered),
168
+ ("modbus_timeouts", Metric::ModbusTimeouts),
169
+ ("modbus_skipped", Metric::ModbusSkipped),
162
170
  ];
163
171
 
164
172
  pub fn name(self) -> &'static str {
@@ -225,8 +233,10 @@ pub const CAPABILITIES: Capabilities = Capabilities {
225
233
  "frames_sent",
226
234
  "frames_received",
227
235
  "modbus_unanswered",
236
+ "modbus_timeouts",
237
+ "modbus_skipped",
228
238
  ],
229
- features: &["imix", "bounded_buffer"],
239
+ features: &["imix", "bounded_buffer", "modbus_outstanding"],
230
240
  notes: &[],
231
241
  };
232
242
 
@@ -527,11 +537,17 @@ fn parse_traffic(value: Value, i: usize) -> Res<Traffic> {
527
537
  None => Q::int(0),
528
538
  Some(v) => number(&v, "poll: delay_ms")?,
529
539
  };
530
- for field in ["outstanding", "timeout_ms"] {
531
- match f.take_or(field) {
532
- None | Some(Value::Null) => {}
533
- Some(_) => return Err(unsupported("polls with one request in flight")),
534
- }
540
+ let one_in_flight = match f.take_or("outstanding") {
541
+ None | Some(Value::Null) => false,
542
+ Some(v) if v.as_u64() == Some(1) => true,
543
+ Some(v) => return Err(format!("poll: outstanding {v}")),
544
+ };
545
+ let timeout_ms = match f.take_or("timeout_ms") {
546
+ None | Some(Value::Null) => None,
547
+ Some(v) => Some(number(&v, "poll: timeout_ms")?),
548
+ };
549
+ if timeout_ms.is_some() && !one_in_flight {
550
+ return Err("poll: timeout_ms needs outstanding 1".to_string());
535
551
  }
536
552
  f.done()?;
537
553
  Ok(Traffic::Poll(Poll {
@@ -540,6 +556,8 @@ fn parse_traffic(value: Value, i: usize) -> Res<Traffic> {
540
556
  count,
541
557
  rate,
542
558
  delay_ms,
559
+ one_in_flight,
560
+ timeout_ms,
543
561
  }))
544
562
  }
545
563
  "publish" => {
@@ -720,14 +738,24 @@ mod tests {
720
738
  .unwrap_err()
721
739
  .contains("unknown field \"x\"")
722
740
  );
723
- for field in ["\"outstanding\": 1", "\"timeout_ms\": 50.0"] {
724
- let poll = format!(
725
- "\"traffic\": [{{\"kind\": \"poll\", \"source\": \"tx\", \"slave\": \"rx\", \"register\": 0, \"count\": 10, \"rate\": 100, \"delay_ms\": 0.0, {field}}}, "
741
+ let poll = |fields: &str| {
742
+ let traffic = format!(
743
+ "\"traffic\": [{{\"kind\": \"poll\", \"source\": \"tx\", \"slave\": \"rx\", \"register\": 0, \"count\": 10, \"rate\": 100, \"delay_ms\": 0.0{fields}}}, "
726
744
  );
727
- assert!(parse(&B1.replace("\"traffic\": [", &poll))
728
- .unwrap_err()
729
- .contains("polls with one request in flight"));
730
- }
745
+ parse(&B1.replace("\"traffic\": [", &traffic))
746
+ };
747
+ let open = poll("").unwrap();
748
+ assert!(!open.polls[0].one_in_flight && open.polls[0].timeout_ms.is_none());
749
+ let closed = poll(", \"outstanding\": 1, \"timeout_ms\": 0.3").unwrap();
750
+ assert!(closed.polls[0].one_in_flight);
751
+ assert_eq!(closed.polls[0].timeout_ms, Some(Q::new(3, 10).unwrap()));
752
+ assert!(poll(", \"outstanding\": 1").unwrap().polls[0].one_in_flight);
753
+ assert!(poll(", \"outstanding\": 2")
754
+ .unwrap_err()
755
+ .contains("poll: outstanding 2"));
756
+ assert!(poll(", \"timeout_ms\": 50.0")
757
+ .unwrap_err()
758
+ .contains("timeout_ms needs outstanding 1"));
731
759
  let poisson = parse(&B1.replace("\"constant\"", "\"poisson\"")).unwrap();
732
760
  assert_eq!(poisson.flows[0].pattern, Pattern::Poisson);
733
761
  let imix = parse(&B1.replace("\"size\": 512", "\"size\": \"imix\"")).unwrap();
@@ -19,6 +19,9 @@
19
19
  //! processes in node order, then metric samplers in observation order;
20
20
  //! - the run stops before the first event at `t = duration`.
21
21
  //!
22
+ //! A poll with one request in flight (ADR-0012) starts its request's timeout
23
+ //! right after the request's Put, as one timeout event: [`Ev::PollTimeout`].
24
+ //!
22
25
  //! The PROFINET watchdog waits on `arrival | timeout`, a SimPy `AnyOf`
23
26
  //! condition, which is reproduced event by event (see [`PnAr`]).
24
27
 
@@ -51,6 +54,8 @@ enum Ev {
51
54
  Watchdog(u32, u32),
52
55
  /// its `arrival | timeout` condition, of AR state and round
53
56
  Condition(u32, u32),
57
+ /// a Modbus request's timeout, of transaction slot and transaction id
58
+ PollTimeout(u32, u64),
54
59
  }
55
60
 
56
61
  #[derive(Clone, Copy)]
@@ -73,12 +78,15 @@ struct Modbus {
73
78
  unit: i16,
74
79
  count: u16,
75
80
  response: bool,
81
+ /// the MBAP transaction id, on polls with one request in flight
82
+ tid: u64,
76
83
  }
77
84
 
78
85
  const NOT_MODBUS: Modbus = Modbus {
79
86
  unit: -1,
80
87
  count: 0,
81
88
  response: false,
89
+ tid: 0,
82
90
  };
83
91
 
84
92
  /// The MQTT fields of a PUBLISH frame; `topic < 0` on any other frame,
@@ -162,13 +170,59 @@ struct Adapter {
162
170
  out: Option<u32>,
163
171
  bytes_received: u128,
164
172
  frames_received: u64,
165
- modbus_requests: u64, // generated by its polls
173
+ modbus_requests: u64, // sent by its polls
166
174
  modbus_responses: u64, // accepted
175
+ modbus_timeouts: u64, // requests timed out (ADR-0012)
176
+ modbus_skipped: u64, // poll instants skipped (ADR-0012)
177
+ /// polls with one request in flight: (slave MAC, transaction slot)
178
+ transactions: Vec<(u32, u32)>,
167
179
  latency_windows: Vec<u32>,
168
180
  modbus_windows: Vec<u32>, // round-trip times of Modbus responses
169
181
  pn: u32, // its PROFINET consumer
170
182
  }
171
183
 
184
+ /// The transaction slot of a poll with one request in flight (ADR-0012,
185
+ /// `_Transaction`): the request outstanding, if any, and when the previous
186
+ /// one completed.
187
+ struct Transaction {
188
+ adapter: u32,
189
+ timeout_ns: Option<u64>,
190
+ sent: u64, // requests sent: the last one's id is sent - 1
191
+ sent_at: u64,
192
+ outstanding: bool,
193
+ completed_at: Option<u64>,
194
+ }
195
+
196
+ impl Transaction {
197
+ /// Whether a request may be sent now: none is outstanding, and the
198
+ /// previous one did not complete at this very instant.
199
+ fn free(&self, now: u64) -> bool {
200
+ !self.outstanding && self.completed_at != Some(now)
201
+ }
202
+
203
+ /// Send a request now: its transaction id.
204
+ fn send(&mut self, now: u64) -> u64 {
205
+ self.sent += 1;
206
+ self.sent_at = now;
207
+ self.outstanding = true;
208
+ self.sent - 1
209
+ }
210
+
211
+ /// Whether a response ends the outstanding request: its own, before the
212
+ /// timeout. Otherwise it is discarded.
213
+ fn accept(&mut self, tid: u64, now: u64) -> bool {
214
+ if !self.outstanding || tid + 1 != self.sent {
215
+ return false;
216
+ }
217
+ if self.timeout_ns.is_some_and(|t| now - self.sent_at >= t) {
218
+ return false;
219
+ }
220
+ self.outstanding = false;
221
+ self.completed_at = Some(now);
222
+ true
223
+ }
224
+ }
225
+
172
226
  /// A PROFINET IO device: consumes its controller's outputs.
173
227
  struct Device {
174
228
  mac: u32,
@@ -248,6 +302,8 @@ struct Periodic {
248
302
  instants: Instants,
249
303
  /// the adapter whose requests a Modbus poll counts
250
304
  requester: Option<u32>,
305
+ /// the transaction slot of a poll with one request in flight
306
+ transaction: Option<u32>,
251
307
  }
252
308
 
253
309
  struct Switch {
@@ -303,6 +359,8 @@ enum Sampled {
303
359
  FramesSent(u32),
304
360
  FramesReceived(u32),
305
361
  ModbusUnanswered(u32),
362
+ ModbusTimeouts(u32),
363
+ ModbusSkipped(u32),
306
364
  }
307
365
 
308
366
  struct Sampler {
@@ -349,6 +407,7 @@ struct Engine {
349
407
  slaves: Vec<Slave>,
350
408
  brokers: Vec<Broker>,
351
409
  periodic: Vec<Periodic>,
410
+ transactions: Vec<Transaction>,
352
411
  devices: Vec<Device>,
353
412
  pn_consumers: Vec<PnConsumer>,
354
413
  pn_ars: Vec<PnAr>,
@@ -554,7 +613,15 @@ impl Engine {
554
613
  for w in &ad.latency_windows {
555
614
  self.windows[*w as usize].push(self.now - fr.created);
556
615
  }
557
- if fr.modbus.response {
616
+ let accepted = fr.modbus.response
617
+ && match ad.transactions.iter().find(|(mac, _)| *mac == fr.src) {
618
+ None => true,
619
+ // a late response: the master has given up on it
620
+ Some(&(_, t)) => {
621
+ self.transactions[t as usize].accept(fr.modbus.tid, self.now)
622
+ }
623
+ };
624
+ if accepted {
558
625
  ad.modbus_responses += 1;
559
626
  for w in &ad.modbus_windows {
560
627
  self.windows[*w as usize].push(self.now - fr.created);
@@ -613,6 +680,7 @@ impl Engine {
613
680
  unit: fr.modbus.unit,
614
681
  count: fr.modbus.count,
615
682
  response: true,
683
+ tid: fr.modbus.tid, // MBAP echoes the transaction id
616
684
  },
617
685
  // the request's origin time: modbus_latency is a round trip
618
686
  ..Frame::new(
@@ -693,16 +761,7 @@ impl Engine {
693
761
  if pg.delayed {
694
762
  pg.delayed = false;
695
763
  } else {
696
- let frame = Frame {
697
- created: self.now,
698
- ..pg.frame
699
- };
700
- let chan = pg.chan;
701
- if let Some(a) = pg.requester {
702
- self.adapters[a as usize].modbus_requests += 1;
703
- }
704
- let f = self.alloc(frame);
705
- self.enqueue(chan, f);
764
+ self.periodic_send(i);
706
765
  }
707
766
  let t = self.periodic[i as usize].instants.next().unwrap();
708
767
  self.schedule(Ev::Timeout(proc), NORMAL, t - self.now);
@@ -719,6 +778,48 @@ impl Engine {
719
778
  }
720
779
  }
721
780
 
781
+ /// A poll or publication at one of its instants. A poll with one request
782
+ /// in flight skips the instant while its slot is not free, and otherwise
783
+ /// starts the request's timeout after its Put, as `_modbus_poll_gen`.
784
+ fn periodic_send(&mut self, i: u32) {
785
+ let now = self.now;
786
+ let pg = &self.periodic[i as usize];
787
+ let (chan, requester, slot) = (pg.chan, pg.requester, pg.transaction);
788
+ let mut frame = Frame {
789
+ created: now,
790
+ ..pg.frame
791
+ };
792
+ let mut timeout = None;
793
+ if let Some(t) = slot {
794
+ let tr = &mut self.transactions[t as usize];
795
+ if !tr.free(now) {
796
+ self.adapters[tr.adapter as usize].modbus_skipped += 1;
797
+ return;
798
+ }
799
+ frame.modbus.tid = tr.send(now);
800
+ timeout = tr.timeout_ns.map(|d| (t, frame.modbus.tid, d));
801
+ }
802
+ if let Some(a) = requester {
803
+ self.adapters[a as usize].modbus_requests += 1;
804
+ }
805
+ let f = self.alloc(frame);
806
+ self.enqueue(chan, f);
807
+ if let Some((t, tid, d)) = timeout {
808
+ // both under 2^63 ns (`tb::ms_to_ns`): the sum fits
809
+ self.schedule(Ev::PollTimeout(t, tid), NORMAL, d);
810
+ }
811
+ }
812
+
813
+ /// The timeout of request *tid*: it times out if still outstanding.
814
+ fn on_poll_timeout(&mut self, t: u32, tid: u64) {
815
+ let tr = &mut self.transactions[t as usize];
816
+ if tr.outstanding && tid + 1 == tr.sent {
817
+ tr.outstanding = false;
818
+ tr.completed_at = Some(self.now);
819
+ self.adapters[tr.adapter as usize].modbus_timeouts += 1;
820
+ }
821
+ }
822
+
722
823
  /// The first gap of a flow's pattern, after its delay.
723
824
  fn flow_begin(&mut self, i: u32, proc: u32) {
724
825
  let fl = &mut self.flows[i as usize];
@@ -1007,6 +1108,12 @@ impl Engine {
1007
1108
  let ad = &self.adapters[*a as usize];
1008
1109
  (Some((ad.modbus_requests - ad.modbus_responses) as f64), 0)
1009
1110
  }
1111
+ Sampled::ModbusTimeouts(a) => {
1112
+ (Some(self.adapters[*a as usize].modbus_timeouts as f64), 0)
1113
+ }
1114
+ Sampled::ModbusSkipped(a) => {
1115
+ (Some(self.adapters[*a as usize].modbus_skipped as f64), 0)
1116
+ }
1010
1117
  };
1011
1118
  let s = &mut self.samplers[i as usize];
1012
1119
  s.last_t = now;
@@ -1036,6 +1143,7 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1036
1143
  slaves: Vec::new(),
1037
1144
  brokers: Vec::new(),
1038
1145
  periodic: Vec::new(),
1146
+ transactions: Vec::new(),
1039
1147
  devices: Vec::new(),
1040
1148
  pn_consumers: Vec::new(),
1041
1149
  pn_ars: Vec::new(),
@@ -1096,6 +1204,9 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1096
1204
  frames_received: 0,
1097
1205
  modbus_requests: 0,
1098
1206
  modbus_responses: 0,
1207
+ modbus_timeouts: 0,
1208
+ modbus_skipped: 0,
1209
+ transactions: Vec::new(),
1099
1210
  latency_windows: Vec::new(),
1100
1211
  modbus_windows: Vec::new(),
1101
1212
  pn,
@@ -1405,6 +1516,7 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1405
1516
  delayed: false,
1406
1517
  instants: Instants::new(delay_ns, tb::interval_ns(publish.rate)?),
1407
1518
  requester: None,
1519
+ transaction: None,
1408
1520
  });
1409
1521
  e.process(Proc::Periodic((e.periodic.len() - 1) as u32));
1410
1522
  }
@@ -1417,16 +1529,33 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1417
1529
  ));
1418
1530
  };
1419
1531
  let delay_ns = tb::ms_to_ns(poll.delay_ms)?;
1532
+ let slave_mac = intern(mac);
1533
+ let transaction = if poll.one_in_flight {
1534
+ e.transactions.push(Transaction {
1535
+ adapter: a,
1536
+ timeout_ns: poll.timeout_ms.map(tb::ms_to_ns).transpose()?,
1537
+ sent: 0,
1538
+ sent_at: 0,
1539
+ outstanding: false,
1540
+ completed_at: None,
1541
+ });
1542
+ let t = (e.transactions.len() - 1) as u32;
1543
+ e.adapters[a as usize].transactions.push((slave_mac, t));
1544
+ Some(t)
1545
+ } else {
1546
+ None
1547
+ };
1420
1548
  e.periodic.push(Periodic {
1421
1549
  frame: Frame {
1422
1550
  modbus: Modbus {
1423
1551
  unit: *unit as i16,
1424
1552
  count: poll.count,
1425
1553
  response: false,
1554
+ tid: 0,
1426
1555
  },
1427
1556
  ..Frame::new(
1428
1557
  e.adapters[a as usize].mac,
1429
- intern(mac),
1558
+ slave_mac,
1430
1559
  MODBUS_REQUEST_BYTES,
1431
1560
  0,
1432
1561
  )
@@ -1436,6 +1565,7 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1436
1565
  delayed: false,
1437
1566
  instants: Instants::new(delay_ns, tb::interval_ns(poll.rate)?),
1438
1567
  requester: Some(a),
1568
+ transaction,
1439
1569
  });
1440
1570
  e.process(Proc::Periodic((e.periodic.len() - 1) as u32));
1441
1571
  }
@@ -1544,6 +1674,8 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1544
1674
  Metric::ModbusUnanswered if adapter => {
1545
1675
  Some(Sampled::ModbusUnanswered(role[target] as u32))
1546
1676
  }
1677
+ Metric::ModbusTimeouts if adapter => Some(Sampled::ModbusTimeouts(role[target] as u32)),
1678
+ Metric::ModbusSkipped if adapter => Some(Sampled::ModbusSkipped(role[target] as u32)),
1547
1679
  _ => None,
1548
1680
  };
1549
1681
  if let Some(what) = what {
@@ -1576,6 +1708,7 @@ pub fn run(sc: &Scenario) -> Result<Outcome, String> {
1576
1708
  Ev::Arrival(r, round) => e.on_arrival(r, round),
1577
1709
  Ev::Watchdog(r, round) => e.on_watchdog(r, round),
1578
1710
  Ev::Condition(r, round) => e.on_condition(r, round),
1711
+ Ev::PollTimeout(t, tid) => e.on_poll_timeout(t, tid),
1579
1712
  }
1580
1713
  }
1581
1714
  Ok(Outcome {
@@ -17,7 +17,7 @@ result = net.simulate(duration=60_000, backend="rust")
17
17
  - **Scope: the whole model, headless.**
18
18
  - Adapters, switches (both QoS modes, learning and converged MAC tables), links, and flows with every pattern and IMIX sizes.
19
19
  - The metrics `throughput`, `latency`, `bytes_sent`, `bytes_received`, `queue_depth` and `utilization`.
20
- - Modbus TCP polling: slaves, polls and `modbus_latency`.
20
+ - Modbus TCP polling: slaves, open-loop polls and polls with one request in flight and a response timeout, `modbus_latency`, `modbus_unanswered`, `modbus_timeouts` and `modbus_skipped`.
21
21
  - MQTT: brokers, publications with QoS 0 and 1, routes and `broker_queue`.
22
22
  - PROFINET RT: devices, controllers' ARs, the watchdog, `pn_latency`, `pn_jitter` and `pn_watchdog_expiries`.
23
23
  - The live and text dashboards need SimPy.
@@ -94,7 +94,7 @@ class SimPyBackend:
94
94
  traffic=_TRAFFIC_KINDS,
95
95
  patterns=_PATTERNS,
96
96
  metrics=frozenset(METRIC_TARGETS),
97
- features=frozenset({"imix", "bounded_buffer"}),
97
+ features=frozenset({"imix", "bounded_buffer", "modbus_outstanding"}),
98
98
  dashboards=True,
99
99
  )
100
100
 
@@ -31,6 +31,8 @@ _UNITS = {
31
31
  "frames_sent": "fr",
32
32
  "frames_received": "fr",
33
33
  "modbus_unanswered": "poll", # 4 characters, as the report's columns allow
34
+ "modbus_timeouts": "poll",
35
+ "modbus_skipped": "poll",
34
36
  }
35
37
 
36
38
 
@@ -24,6 +24,8 @@ MetricName = Literal[
24
24
  "frames_sent",
25
25
  "frames_received",
26
26
  "modbus_unanswered",
27
+ "modbus_timeouts",
28
+ "modbus_skipped",
27
29
  ]
28
30
 
29
31
 
@@ -94,6 +94,9 @@ METRIC_TARGETS: dict[str, tuple[type, ...] | None] = {
94
94
  "frames_sent": (AdapterNode,),
95
95
  "frames_received": (AdapterNode,),
96
96
  "modbus_unanswered": (AdapterNode,),
97
+ # ADR-0012: one Modbus request in flight
98
+ "modbus_timeouts": (AdapterNode,),
99
+ "modbus_skipped": (AdapterNode,),
97
100
  }
98
101
 
99
102
  SWITCH_MODES = ("store-and-forward", "cut-through")
@@ -266,6 +269,8 @@ def _check_outstanding(t: Poll) -> None:
266
269
  raise _fail(
267
270
  t, f"timeout must be at least 1 ns (0.000001 ms) and finite, got {t.timeout_ms!r}"
268
271
  )
272
+ if timebase.ms_to_ns(t.timeout_ms) > timebase.MAX_NS:
273
+ raise _fail(t, f"timeout must be at most 2^63 - 1 ns (292 years), got {t.timeout_ms!r} ms")
269
274
 
270
275
 
271
276
  def _largest_frame(t: TrafficSpec) -> int: