smolpy 1.10.3.dev2__tar.gz → 1.10.3.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 (156) hide show
  1. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/PKG-INFO +10 -5
  2. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/README.md +8 -3
  3. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/__main__.py +19 -0
  4. smolpy-1.10.3.dev8/benchmarks/loss.py +194 -0
  5. smolpy-1.10.3.dev8/benchmarks/results/2026-11-23-1228-simpy-rust-ns3-jaws-zbook-bounded-buffers.json +4349 -0
  6. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0004-execution-backends.md +1 -1
  7. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0011-bounded-switch-buffers.md +10 -1
  8. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/backends.md +48 -1
  9. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/benchmarks.md +5 -1
  10. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/dsl-reference.md +18 -2
  11. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/language-reference.md +12 -1
  12. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/model-semantics.md +33 -6
  13. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/profinet.md +2 -2
  14. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/roadmap.md +14 -1
  15. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/README.md +23 -2
  16. smolpy-1.10.3.dev8/examples/example_bounded_buffer.smol +39 -0
  17. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/pyproject.toml +7 -3
  18. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/src/scenario.rs +59 -13
  19. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/src/sim.rs +96 -5
  20. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/backends.py +7 -2
  21. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/network.py +4 -0
  22. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/observation.py +5 -0
  23. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/model/validate.py +6 -0
  24. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/ns3/__init__.py +19 -9
  25. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/ns3/cpp/smol-ns3.cc +112 -14
  26. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/sim/engine.py +99 -5
  27. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/viz/dashboard.py +5 -0
  28. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/viz/text_dashboard.py +5 -0
  29. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/equivalence/harness.py +34 -3
  30. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/equivalence/scenarios.py +91 -0
  31. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/equivalence/test_equivalence.py +4 -2
  32. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_benchmarks.py +31 -0
  33. smolpy-1.10.3.dev8/tests/test_buffers.py +603 -0
  34. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_ns3.py +2 -2
  35. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/uv.lock +8 -8
  36. smolpy-1.10.3.dev2/tests/test_buffers.py +0 -196
  37. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/ci.yml +0 -0
  38. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/dev-build.yml +0 -0
  39. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/docker-image.yml +0 -0
  40. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/docs.yml +0 -0
  41. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/github-release.yml +0 -0
  42. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/ns3-base.yml +0 -0
  43. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/publish.yml +0 -0
  44. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/release.yml +0 -0
  45. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.github/workflows/rust-wheels.yml +0 -0
  46. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/.gitignore +0 -0
  47. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/LICENSE +0 -0
  48. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/__init__.py +0 -0
  49. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/load.py +0 -0
  50. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  51. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  52. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  53. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  54. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  55. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  56. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  57. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/results/2026-11-16-1839-simpy-ns3-jaws-zbook-tcp-under-load.json +0 -0
  58. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/runner.py +0 -0
  59. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/scenarios.py +0 -0
  60. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/benchmarks/worker.py +0 -0
  61. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/Dockerfile +0 -0
  62. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/Dockerfile.dockerignore +0 -0
  63. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/Dockerfile.ns3 +0 -0
  64. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/Dockerfile.ns3.dockerignore +0 -0
  65. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/ns3-base/Dockerfile +0 -0
  66. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/ns3-base/smoke.cc +0 -0
  67. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docker/smoke.smol +0 -0
  68. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0001-protocol-package-structure.md +0 -0
  69. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  70. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0003-smol-external-dsl.md +0 -0
  71. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0005-profinet-rt.md +0 -0
  72. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  73. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  74. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  75. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +0 -0
  76. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  77. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/dashboard.md +0 -0
  78. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/examples.md +0 -0
  79. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/index.md +0 -0
  80. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/modbus.md +0 -0
  81. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/mqtt.md +0 -0
  82. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/scenario-model.md +0 -0
  83. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/docs/simulation-engine.md +0 -0
  84. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example.py +0 -0
  85. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example.smol +0 -0
  86. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_10_clients.py +0 -0
  87. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_12_clients.py +0 -0
  88. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_20_clients.py +0 -0
  89. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_file_transfer.py +0 -0
  90. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_modbus.py +0 -0
  91. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_mqtt.py +0 -0
  92. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_profinet.py +0 -0
  93. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_profinet.smol +0 -0
  94. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_staggered_transfer.py +0 -0
  95. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/examples/example_two_tier.py +0 -0
  96. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/mkdocs.yml +0 -0
  97. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/Cargo.lock +0 -0
  98. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/Cargo.toml +0 -0
  99. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/Cargo.toml +0 -0
  100. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/src/frames.rs +0 -0
  101. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/src/lib.rs +0 -0
  102. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/src/rng.rs +0 -0
  103. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smol-engine/src/timebase.rs +0 -0
  104. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  105. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smolpy-engine-rs/README.md +0 -0
  106. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  107. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  108. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  109. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/__init__.py +0 -0
  110. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/_worker.py +0 -0
  111. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/batch.py +0 -0
  112. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/cli.py +0 -0
  113. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/__init__.py +0 -0
  114. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/adapter.py +0 -0
  115. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/batch.py +0 -0
  116. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/link.py +0 -0
  117. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/core/node.py +0 -0
  118. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/ethernet/__init__.py +0 -0
  119. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/ethernet/switch.py +0 -0
  120. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/lang/__init__.py +0 -0
  121. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/lang/ast.py +0 -0
  122. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/lang/errors.py +0 -0
  123. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/lang/grammar.lark +0 -0
  124. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/lang/interpreter.py +0 -0
  125. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/lang/transformer.py +0 -0
  126. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/modbus/__init__.py +0 -0
  127. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/modbus/slave.py +0 -0
  128. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/model/__init__.py +0 -0
  129. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/model/frames.py +0 -0
  130. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/model/scenario.py +0 -0
  131. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/model/streams.py +0 -0
  132. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/model/timebase.py +0 -0
  133. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/mqtt/__init__.py +0 -0
  134. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/mqtt/broker.py +0 -0
  135. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/profinet/__init__.py +0 -0
  136. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/profinet/device.py +0 -0
  137. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/sim/__init__.py +0 -0
  138. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/stats.py +0 -0
  139. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/src/smolpy/viz/__init__.py +0 -0
  140. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/__init__.py +0 -0
  141. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/equivalence/__init__.py +0 -0
  142. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/equivalence/test_rust_timebase.py +0 -0
  143. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_backends.py +0 -0
  144. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_batch.py +0 -0
  145. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_cli.py +0 -0
  146. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_dsl.py +0 -0
  147. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_engine_ir.py +0 -0
  148. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_lang.py +0 -0
  149. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_model.py +0 -0
  150. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_profinet.py +0 -0
  151. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_semantics.py +0 -0
  152. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_simulation.py +0 -0
  153. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_stats.py +0 -0
  154. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_sweep.py +0 -0
  155. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_timebase.py +0 -0
  156. {smolpy-1.10.3.dev2 → smolpy-1.10.3.dev8}/tests/test_validate.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: smolpy
3
- Version: 1.10.3.dev2
3
+ Version: 1.10.3.dev8
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.8; extra == 'rust'
26
+ Requires-Dist: smolpy-engine-rs>=1.10.3.dev0; extra == 'rust'
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  # SMOLPy
@@ -64,7 +64,7 @@ SMOLPy lets you describe a network topology in pure Python, define traffic flows
64
64
  | **Modbus TCP** | TCP/IP | Request / response polling (Read Holding Registers, FC 03) | `ModbusSlave`, `Adapter.polls()` | `modbus_slave`, `poll` | `modbus_latency` |
65
65
  | **PROFINET RT** | Layer 2 (EtherType 0x8892), 802.1Q priority 6 | Cyclic producer / consumer exchange with watchdog | `ProfinetDevice`, `Adapter.controls()` | `profinet_device`, `control` | `pn_latency`, `pn_jitter`, `pn_watchdog_expiries` |
66
66
 
67
- Infrastructure: MAC-learning **switches** with 802.1Q strict-priority egress queues (`qos="strict"`, or `qos="fifo"` to disable prioritisation). One `Adapter` can act in several roles at once — e.g. a PLC that is a Modbus master, an MQTT publisher and a PROFINET controller.
67
+ Infrastructure: MAC-learning **switches** with 802.1Q strict-priority egress queues (`qos="strict"`, or `qos="fifo"` to disable prioritisation), unbounded or bounded with tail drop (`buffer=` in bytes). One `Adapter` can act in several roles at once — e.g. a PLC that is a Modbus master, an MQTT publisher and a PROFINET controller.
68
68
 
69
69
  **Not supported (yet):** PROFINET IRT, PROFIBUS, EtherNet/IP, EtherCAT, OPC UA, Modbus RTU (serial), and Modbus write function codes. See the [Architecture Decision Records](https://jwszolek.github.io/SMOLPy/adr/0001-protocol-package-structure/) for what is planned.
70
70
 
@@ -309,7 +309,6 @@ net.observe(metric, on=node, every=interval_ms)
309
309
  |---|---|---|
310
310
  | `throughput` | Mb/s | Adapter |
311
311
  | `latency` | µs | Adapter |
312
- | `frame_loss` | % | Adapter |
313
312
  | `bytes_sent` | MB | Adapter (sender) |
314
313
  | `bytes_received` | MB | Adapter (receiver) |
315
314
  | `queue_depth` | frames | Switch |
@@ -319,6 +318,11 @@ net.observe(metric, on=node, every=interval_ms)
319
318
  | `pn_latency` | µs | Adapter (controller), ProfinetDevice |
320
319
  | `pn_jitter` | µs | Adapter (controller), ProfinetDevice |
321
320
  | `pn_watchdog_expiries` | count | Adapter (controller), ProfinetDevice |
321
+ | `drops` | frames | Switch: dropped by its buffers in the window |
322
+ | `drops_total` | frames | Switch: dropped by its buffers so far |
323
+ | `frames_sent` | frames | Adapter (sender) |
324
+ | `frames_received` | frames | Adapter (receiver) |
325
+ | `modbus_unanswered` | polls | Adapter (master): polls without a response so far, lost or in flight |
322
326
 
323
327
  ### Simulation
324
328
 
@@ -474,7 +478,7 @@ frame_size = max(64, 14 (Ethernet) + 4 (802.1Q tag) + 2 (FrameID) + io_bytes + 4
474
478
 
475
479
  ### Not modelled
476
480
 
477
- IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyclic record data, alarms, media redundancy (MRP). Switch buffers are unbounded, so frames are delayed but never dropped.
481
+ IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyclic record data, alarms, media redundancy (MRP). Switch buffers are unbounded unless a switch sets `buffer`. With it, a full port drops RT frames too, and the watchdog expires on the gap.
478
482
 
479
483
  ### Dashboard
480
484
 
@@ -512,6 +516,7 @@ The model every engine implements:
512
516
  - **MAC-learning switch** — each switch pre-seeds its forwarding table from the topology wiring, eliminating spurious flooding toward silent endpoints (e.g. a server that only receives). Dynamic learning still operates for traffic through intermediate switches.
513
517
  - **Store-and-forward model** — transmission delay + propagation delay per hop.
514
518
  - **Queuing** — each link direction has its own egress queue with 8 strict 802.1Q priority classes (FIFO within a class, non-preemptive); `qos="fifo"` on a switch ignores priorities. `queue_depth` reports buffered frames at the switch's outbound ports.
519
+ - **Bounded buffers** — a switch with `buffer` (bytes per port) drops a frame that does not fit, with tail drop: delay is capped and loss appears, as on real switches near saturation ([ADR-0011](https://jwszolek.github.io/SMOLPy/adr/0011-bounded-switch-buffers/)). Without it queues are unbounded.
515
520
  - **Traffic shaping** — constant, Poisson, Pareto-burst and batch patterns; IMIX frame-size distribution.
516
521
  - **Live mode** (SimPy only) — simulation runs in 200 chunks (~8 s total wall time); the dashboard reads shared metric arrays between chunks via Python's GIL.
517
522
 
@@ -36,7 +36,7 @@ SMOLPy lets you describe a network topology in pure Python, define traffic flows
36
36
  | **Modbus TCP** | TCP/IP | Request / response polling (Read Holding Registers, FC 03) | `ModbusSlave`, `Adapter.polls()` | `modbus_slave`, `poll` | `modbus_latency` |
37
37
  | **PROFINET RT** | Layer 2 (EtherType 0x8892), 802.1Q priority 6 | Cyclic producer / consumer exchange with watchdog | `ProfinetDevice`, `Adapter.controls()` | `profinet_device`, `control` | `pn_latency`, `pn_jitter`, `pn_watchdog_expiries` |
38
38
 
39
- Infrastructure: MAC-learning **switches** with 802.1Q strict-priority egress queues (`qos="strict"`, or `qos="fifo"` to disable prioritisation). One `Adapter` can act in several roles at once — e.g. a PLC that is a Modbus master, an MQTT publisher and a PROFINET controller.
39
+ Infrastructure: MAC-learning **switches** with 802.1Q strict-priority egress queues (`qos="strict"`, or `qos="fifo"` to disable prioritisation), unbounded or bounded with tail drop (`buffer=` in bytes). One `Adapter` can act in several roles at once — e.g. a PLC that is a Modbus master, an MQTT publisher and a PROFINET controller.
40
40
 
41
41
  **Not supported (yet):** PROFINET IRT, PROFIBUS, EtherNet/IP, EtherCAT, OPC UA, Modbus RTU (serial), and Modbus write function codes. See the [Architecture Decision Records](https://jwszolek.github.io/SMOLPy/adr/0001-protocol-package-structure/) for what is planned.
42
42
 
@@ -281,7 +281,6 @@ net.observe(metric, on=node, every=interval_ms)
281
281
  |---|---|---|
282
282
  | `throughput` | Mb/s | Adapter |
283
283
  | `latency` | µs | Adapter |
284
- | `frame_loss` | % | Adapter |
285
284
  | `bytes_sent` | MB | Adapter (sender) |
286
285
  | `bytes_received` | MB | Adapter (receiver) |
287
286
  | `queue_depth` | frames | Switch |
@@ -291,6 +290,11 @@ net.observe(metric, on=node, every=interval_ms)
291
290
  | `pn_latency` | µs | Adapter (controller), ProfinetDevice |
292
291
  | `pn_jitter` | µs | Adapter (controller), ProfinetDevice |
293
292
  | `pn_watchdog_expiries` | count | Adapter (controller), ProfinetDevice |
293
+ | `drops` | frames | Switch: dropped by its buffers in the window |
294
+ | `drops_total` | frames | Switch: dropped by its buffers so far |
295
+ | `frames_sent` | frames | Adapter (sender) |
296
+ | `frames_received` | frames | Adapter (receiver) |
297
+ | `modbus_unanswered` | polls | Adapter (master): polls without a response so far, lost or in flight |
294
298
 
295
299
  ### Simulation
296
300
 
@@ -446,7 +450,7 @@ frame_size = max(64, 14 (Ethernet) + 4 (802.1Q tag) + 2 (FrameID) + io_bytes + 4
446
450
 
447
451
  ### Not modelled
448
452
 
449
- IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyclic record data, alarms, media redundancy (MRP). Switch buffers are unbounded, so frames are delayed but never dropped.
453
+ IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyclic record data, alarms, media redundancy (MRP). Switch buffers are unbounded unless a switch sets `buffer`. With it, a full port drops RT frames too, and the watchdog expires on the gap.
450
454
 
451
455
  ### Dashboard
452
456
 
@@ -484,6 +488,7 @@ The model every engine implements:
484
488
  - **MAC-learning switch** — each switch pre-seeds its forwarding table from the topology wiring, eliminating spurious flooding toward silent endpoints (e.g. a server that only receives). Dynamic learning still operates for traffic through intermediate switches.
485
489
  - **Store-and-forward model** — transmission delay + propagation delay per hop.
486
490
  - **Queuing** — each link direction has its own egress queue with 8 strict 802.1Q priority classes (FIFO within a class, non-preemptive); `qos="fifo"` on a switch ignores priorities. `queue_depth` reports buffered frames at the switch's outbound ports.
491
+ - **Bounded buffers** — a switch with `buffer` (bytes per port) drops a frame that does not fit, with tail drop: delay is capped and loss appears, as on real switches near saturation ([ADR-0011](https://jwszolek.github.io/SMOLPy/adr/0011-bounded-switch-buffers/)). Without it queues are unbounded.
487
492
  - **Traffic shaping** — constant, Poisson, Pareto-burst and batch patterns; IMIX frame-size distribution.
488
493
  - **Live mode** (SimPy only) — simulation runs in 200 chunks (~8 s total wall time); the dashboard reads shared metric arrays between chunks via Python's GIL.
489
494
 
@@ -7,6 +7,8 @@ python -m benchmarks batch --scenario B3 --frames 1M --runs 16 --jobs 8 [--backe
7
7
  python -m benchmarks profile --scenario B1 --frames 1M --tool cprofile|tracemalloc|py-spy
8
8
  python -m benchmarks load [--loads 0.5 0.9 1.0 1.2] [--duration 20000] [--backend simpy ns3]
9
9
  python -m benchmarks load-summary benchmarks/results/<file>.json
10
+ python -m benchmarks loss [--loads 0.93 0.996] [--duration 30000] [--backend simpy rust ns3]
11
+ python -m benchmarks loss-summary benchmarks/results/<file>.json
10
12
  """
11
13
 
12
14
  from __future__ import annotations
@@ -18,6 +20,7 @@ import subprocess
18
20
  import sys
19
21
  from pathlib import Path
20
22
 
23
+ from benchmarks import loss
21
24
  from benchmarks.load import DURATION_MS, LOADS, run_load, summarize_load
22
25
  from benchmarks.runner import parse_size, run_batch, run_suite, size_label, summarize
23
26
 
@@ -90,6 +93,16 @@ def main() -> None:
90
93
  load_summ = sub.add_parser("load-summary", help="markdown table of a load results file")
91
94
  load_summ.add_argument("file", type=Path)
92
95
 
96
+ lossy = sub.add_parser("loss", help="the testbed of ADR-0011, bounded buffers, every engine")
97
+ lossy.add_argument("--loads", nargs="+", type=float, default=list(loss.LOADS))
98
+ lossy.add_argument("--duration", type=float, default=loss.DURATION_MS, help="simulated ms")
99
+ lossy.add_argument("--backend", nargs="+", default=list(loss.ENGINES))
100
+ lossy.add_argument("--label", default="bounded-buffers")
101
+ lossy.add_argument("--out", type=Path, default=None)
102
+
103
+ loss_summ = sub.add_parser("loss-summary", help="markdown table of a loss results file")
104
+ loss_summ.add_argument("file", type=Path)
105
+
93
106
  a = p.parse_args()
94
107
  if a.cmd == "run":
95
108
  sizes = [parse_size(s) for s in a.frames]
@@ -106,6 +119,12 @@ def main() -> None:
106
119
  print(summarize_load(out, *a.backend[:2]) if len(a.backend) > 1 else "")
107
120
  elif a.cmd == "load-summary":
108
121
  print(summarize_load(a.file))
122
+ elif a.cmd == "loss":
123
+ out = loss.run_loss(a.loads, a.duration, a.backend, a.label, a.out)
124
+ print(f"\nresults: {out}\n")
125
+ print(loss.summarize_loss(out))
126
+ elif a.cmd == "loss-summary":
127
+ print(loss.summarize_loss(a.file))
109
128
  elif a.cmd == "batch":
110
129
  frames = parse_size(a.frames)
111
130
  r = run_batch(a.scenario, frames, a.metrics, a.runs, a.jobs, a.timeout, a.seed, a.backend)
@@ -0,0 +1,194 @@
1
+ """Bounded switch buffers on the three engines: the testbed of ADR-0011.
2
+
3
+ Scenario T1, after a hardware testbed (a TP-Link LS108GP, an unmanaged
4
+ 8 x 1 Gb/s store-and-forward switch): a Raspberry Pi on a 1 Gb/s port sends
5
+ Poisson UDP traffic of 1 518 B frames to a laptop whose port runs at
6
+ 100 Mb/s, and the laptop polls a Modbus TCP server on the Pi every 10 ms.
7
+ The responses share the laptop's port with the UDP stream. Here the Pi is
8
+ two stations, a UDP source and a Modbus slave, each on a 1 Gb/s port.
9
+
10
+ rho is the UDP stream's wire bits as a share of the laptop's 100 Mb/s; the
11
+ Modbus responses add 0.085 %. Two buffers per port:
12
+ - 115 000 B, what the testbed's capped RTT points to. A full queue holds 75
13
+ UDP frames (113 850 B) and keeps room for a response (86 B), so only UDP
14
+ frames are lost;
15
+ - 113 900 B, 75 UDP frames and 50 B: a full queue drops responses too, so
16
+ polls are lost, where SimPy and Rust lose them and ns-3's TCP retransmits.
17
+
18
+ Each load runs with several seeds on every engine. SimPy and ns-3 draw the
19
+ same UDP stream for a seed; Rust draws its own, a different sample of the
20
+ same process. The record keeps, per run:
21
+ - the Modbus round trip: mean, median, p99 and maximum of its per-window
22
+ means over 1 ms windows. Polls are 10 ms apart, so a window holds one
23
+ response, unless TCP delivers several at once after a retransmission;
24
+ - the polls without a response at the end, lost and in flight;
25
+ - the share of frames the switch dropped, of the frames the Pi sent.
26
+
27
+ SimPy and Rust lose a frame for good; ns-3 runs Modbus over its TCP, which
28
+ retransmits it.
29
+
30
+ python -m benchmarks loss [--loads 0.93 0.996] [--duration 30000]
31
+ """
32
+
33
+ from __future__ import annotations
34
+
35
+ import datetime as dt
36
+ import json
37
+ import math
38
+ import statistics
39
+ from pathlib import Path
40
+
41
+ from benchmarks.runner import RESULTS_DIR, environment
42
+ from smolpy import Network, backends
43
+ from smolpy.model import Scenario
44
+ from smolpy.model.frames import WIRE_OVERHEAD_BYTES
45
+
46
+ LAPTOP_MBPS = 100
47
+ FRAME = 1_518
48
+ BUFFER = 115_000
49
+ BUFFERS = (BUFFER, 75 * FRAME + 50)
50
+ POLL_RATE = 100 # polls/s
51
+ REGISTERS = 10
52
+ LOADS = (0.90, 0.93, 0.96, 0.98, 0.99, 0.996, 1.0, 1.02, 1.05)
53
+ DURATION_MS = 30_000
54
+ ENGINES = ("simpy", "rust", "ns3")
55
+ SEEDS = (1, 2, 3, 4, 5)
56
+ # the testbed, at the loads it was measured at
57
+ MEASURED = {
58
+ 0.93: "RTT as SMOLPy's: mean, median, p90 and p99 within a few percent",
59
+ 0.996: "RTT capped at about 9.8 ms; 0.09 % of UDP frames lost",
60
+ }
61
+
62
+
63
+ def scenario(
64
+ rho: float,
65
+ duration_ms: float = DURATION_MS,
66
+ buffer: int | None = BUFFER,
67
+ seed: int = SEEDS[0],
68
+ ) -> Scenario:
69
+ """T1 with the UDP stream at *rho* of the laptop's port."""
70
+ net = Network("T1")
71
+ sw = net.switch("sw", ports=3, buffer=buffer)
72
+ pi = net.adapter("pi", ip="10.0.0.1")
73
+ server = net.modbus_slave("server", ip="10.0.0.3", unit_id=1)
74
+ laptop = net.adapter("laptop", ip="10.0.0.2")
75
+ net.link(pi, sw, speed=1_000, length=2)
76
+ net.link(server, sw, speed=1_000, length=2)
77
+ net.link(laptop, sw, speed=LAPTOP_MBPS, length=2)
78
+ rate = rho * LAPTOP_MBPS * 1e6 / ((FRAME + WIRE_OVERHEAD_BYTES) * 8)
79
+ pi.sends(laptop, rate=rate, size=FRAME, pattern="poisson")
80
+ laptop.polls(server, register=0, count=REGISTERS, rate=POLL_RATE)
81
+ net.observe("modbus_latency", on=laptop, every=1)
82
+ end = duration_ms - 1 # the last sample, at the end of the run
83
+ net.observe("modbus_unanswered", on=laptop, every=end)
84
+ net.observe("frames_sent", on=pi, every=end)
85
+ net.observe("drops_total", on=sw, every=end)
86
+ return net.to_scenario(duration=duration_ms, seed=seed)
87
+
88
+
89
+ def _summary(metrics: dict[str, list[tuple[float, float]]]) -> dict[str, float]:
90
+ rtt = [v / 1_000 for _, v in metrics["modbus_latency:laptop"]] # ms
91
+ last = {k: (s[-1][1] if s else math.nan) for k, s in metrics.items()}
92
+ sent = last["frames_sent:pi"]
93
+ q = statistics.quantiles(rtt, n=100) if len(rtt) > 1 else [math.nan] * 99
94
+ return {
95
+ "rtt_mean_ms": statistics.fmean(rtt) if rtt else math.nan,
96
+ "rtt_median_ms": q[49],
97
+ "rtt_p99_ms": q[98],
98
+ "rtt_max_ms": max(rtt, default=math.nan),
99
+ "unanswered": last["modbus_unanswered:laptop"],
100
+ "dropped": last["drops_total:sw"] / sent if sent else math.nan,
101
+ }
102
+
103
+
104
+ def run_loss(
105
+ loads: list[float],
106
+ duration_ms: float,
107
+ engines: list[str],
108
+ label: str = "bounded-buffers",
109
+ out: Path | None = None,
110
+ seeds: tuple[int, ...] = SEEDS,
111
+ buffers: tuple[int, ...] = BUFFERS,
112
+ ) -> Path:
113
+ env = environment()
114
+ stamp = dt.datetime.now().strftime("%Y-%m-%d-%H%M")
115
+ out = out or RESULTS_DIR / f"{stamp}-{'-'.join(engines)}-{env['host']}-{label}.json"
116
+ out.parent.mkdir(parents=True, exist_ok=True)
117
+ doc = {
118
+ "format": "smolpy-loss",
119
+ "version": 1,
120
+ "label": label,
121
+ "created": dt.datetime.now().isoformat(timespec="seconds"),
122
+ "environment": env,
123
+ "scenario": "T1",
124
+ "duration_ms": duration_ms,
125
+ "seeds": list(seeds),
126
+ "runs": [],
127
+ }
128
+ for buffer in buffers:
129
+ for rho in loads:
130
+ for seed in seeds:
131
+ sc = scenario(rho, duration_ms, buffer, seed)
132
+ for engine in engines:
133
+ result = backends.get(engine).run(sc)
134
+ record = {
135
+ "buffer_bytes": buffer,
136
+ "rho": rho,
137
+ "seed": seed,
138
+ "backend": engine,
139
+ "events": result.stats.events,
140
+ "wall_s": result.stats.wall_s,
141
+ "summary": _summary(result.metrics),
142
+ }
143
+ doc["runs"].append(record)
144
+ out.write_text(json.dumps(doc, indent=1)) # keep partial progress
145
+ s = record["summary"]
146
+ print(
147
+ f"buffer {buffer} rho {rho:5.3f} seed {seed} {engine:6s}"
148
+ f" RTT median {s['rtt_median_ms']:7.3f} p99 {s['rtt_p99_ms']:8.3f}"
149
+ f" max {s['rtt_max_ms']:9.3f} ms unanswered {s['unanswered']:4.0f}"
150
+ f" dropped {s['dropped']:.4%} ({record['wall_s']:.1f} s)",
151
+ flush=True,
152
+ )
153
+ return out
154
+
155
+
156
+ def summarize_loss(path: Path) -> str:
157
+ """Markdown tables, one per buffer: each load and engine, the mean over
158
+ the seeds, with the range for the RTT median and the share dropped."""
159
+ doc = json.loads(path.read_text())
160
+ groups: dict[tuple[int, float, str], list[dict[str, float]]] = {}
161
+ for r in doc["runs"]:
162
+ groups.setdefault((r["buffer_bytes"], r["rho"], r["backend"]), []).append(r["summary"])
163
+ lines = [
164
+ f"T1, {doc['duration_ms'] / 1000:g} s per run, seeds {doc['seeds']}:"
165
+ " means over the seeds, [min, max] in brackets."
166
+ ]
167
+ for buffer in sorted({b for b, _, _ in groups}, reverse=True):
168
+ lines += [
169
+ "",
170
+ f"Buffer {buffer} B per port.",
171
+ "",
172
+ "| rho | engine | RTT median (ms) | RTT p99 (ms) | RTT max (ms) | unanswered"
173
+ " | dropped |",
174
+ "|---|---|---|---|---|---|---|",
175
+ ]
176
+ for (b, rho, engine), runs in groups.items():
177
+ if b != buffer:
178
+ continue
179
+
180
+ def mean(key: str, runs: list[dict[str, float]] = runs) -> float:
181
+ return statistics.fmean(s[key] for s in runs)
182
+
183
+ def span(key: str, fmt: str, runs: list[dict[str, float]] = runs) -> str:
184
+ values = [s[key] for s in runs]
185
+ return f"[{format(min(values), fmt)}, {format(max(values), fmt)}]"
186
+
187
+ lines.append(
188
+ f"| {rho:.3f} | {engine}"
189
+ f" | {mean('rtt_median_ms'):.3f} {span('rtt_median_ms', '.2f')}"
190
+ f" | {mean('rtt_p99_ms'):.3f} | {max(s['rtt_max_ms'] for s in runs):.3f}"
191
+ f" | {mean('unanswered'):.1f}"
192
+ f" | {mean('dropped'):.3%} {span('dropped', '.2%')} |"
193
+ )
194
+ return "\n".join(lines)