smolpy 1.10.2.dev2__tar.gz → 1.10.3.dev2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/docker-image.yml +64 -12
  2. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/PKG-INFO +38 -8
  3. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/README.md +37 -7
  4. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0004-execution-backends.md +1 -1
  5. smolpy-1.10.3.dev2/docs/adr/0011-bounded-switch-buffers.md +198 -0
  6. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/backends.md +2 -2
  7. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/roadmap.md +2 -2
  8. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/scenario-model.md +2 -2
  9. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/mkdocs.yml +1 -0
  10. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/src/scenario.rs +11 -1
  11. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/backends.py +5 -1
  12. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/network.py +2 -1
  13. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/ethernet/switch.py +9 -1
  14. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/lang/ast.py +1 -0
  15. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/lang/interpreter.py +1 -0
  16. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/lang/transformer.py +20 -0
  17. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/model/frames.py +1 -0
  18. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/model/scenario.py +13 -1
  19. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/model/validate.py +42 -1
  20. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/ns3/__init__.py +4 -0
  21. smolpy-1.10.3.dev2/tests/test_buffers.py +196 -0
  22. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/ci.yml +0 -0
  23. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/dev-build.yml +0 -0
  24. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/docs.yml +0 -0
  25. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/github-release.yml +0 -0
  26. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/ns3-base.yml +0 -0
  27. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/publish.yml +0 -0
  28. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/release.yml +0 -0
  29. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.github/workflows/rust-wheels.yml +0 -0
  30. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/.gitignore +0 -0
  31. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/LICENSE +0 -0
  32. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/__init__.py +0 -0
  33. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/__main__.py +0 -0
  34. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/load.py +0 -0
  35. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  36. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  37. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  38. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  39. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  40. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  41. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  42. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/results/2026-11-16-1839-simpy-ns3-jaws-zbook-tcp-under-load.json +0 -0
  43. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/runner.py +0 -0
  44. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/scenarios.py +0 -0
  45. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/benchmarks/worker.py +0 -0
  46. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/Dockerfile +0 -0
  47. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/Dockerfile.dockerignore +0 -0
  48. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/Dockerfile.ns3 +0 -0
  49. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/Dockerfile.ns3.dockerignore +0 -0
  50. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/ns3-base/Dockerfile +0 -0
  51. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/ns3-base/smoke.cc +0 -0
  52. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docker/smoke.smol +0 -0
  53. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0001-protocol-package-structure.md +0 -0
  54. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  55. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0003-smol-external-dsl.md +0 -0
  56. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0005-profinet-rt.md +0 -0
  57. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  58. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  59. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  60. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +0 -0
  61. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  62. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/benchmarks.md +0 -0
  63. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/dashboard.md +0 -0
  64. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/dsl-reference.md +0 -0
  65. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/examples.md +0 -0
  66. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/index.md +0 -0
  67. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/language-reference.md +0 -0
  68. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/modbus.md +0 -0
  69. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/model-semantics.md +0 -0
  70. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/mqtt.md +0 -0
  71. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/profinet.md +0 -0
  72. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/docs/simulation-engine.md +0 -0
  73. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/README.md +0 -0
  74. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example.py +0 -0
  75. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example.smol +0 -0
  76. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_10_clients.py +0 -0
  77. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_12_clients.py +0 -0
  78. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_20_clients.py +0 -0
  79. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_file_transfer.py +0 -0
  80. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_modbus.py +0 -0
  81. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_mqtt.py +0 -0
  82. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_profinet.py +0 -0
  83. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_profinet.smol +0 -0
  84. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_staggered_transfer.py +0 -0
  85. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/examples/example_two_tier.py +0 -0
  86. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/pyproject.toml +0 -0
  87. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/Cargo.lock +0 -0
  88. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/Cargo.toml +0 -0
  89. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/Cargo.toml +0 -0
  90. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/src/frames.rs +0 -0
  91. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/src/lib.rs +0 -0
  92. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/src/rng.rs +0 -0
  93. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/src/sim.rs +0 -0
  94. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smol-engine/src/timebase.rs +0 -0
  95. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  96. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smolpy-engine-rs/README.md +0 -0
  97. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  98. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  99. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  100. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/__init__.py +0 -0
  101. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/_worker.py +0 -0
  102. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/batch.py +0 -0
  103. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/cli.py +0 -0
  104. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/__init__.py +0 -0
  105. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/adapter.py +0 -0
  106. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/batch.py +0 -0
  107. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/link.py +0 -0
  108. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/node.py +0 -0
  109. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/core/observation.py +0 -0
  110. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/ethernet/__init__.py +0 -0
  111. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/lang/__init__.py +0 -0
  112. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/lang/errors.py +0 -0
  113. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/lang/grammar.lark +0 -0
  114. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/modbus/__init__.py +0 -0
  115. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/modbus/slave.py +0 -0
  116. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/model/__init__.py +0 -0
  117. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/model/streams.py +0 -0
  118. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/model/timebase.py +0 -0
  119. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/mqtt/__init__.py +0 -0
  120. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/mqtt/broker.py +0 -0
  121. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/ns3/cpp/smol-ns3.cc +0 -0
  122. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/profinet/__init__.py +0 -0
  123. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/profinet/device.py +0 -0
  124. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/sim/__init__.py +0 -0
  125. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/sim/engine.py +0 -0
  126. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/stats.py +0 -0
  127. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/viz/__init__.py +0 -0
  128. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/viz/dashboard.py +0 -0
  129. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/src/smolpy/viz/text_dashboard.py +0 -0
  130. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/__init__.py +0 -0
  131. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/equivalence/__init__.py +0 -0
  132. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/equivalence/harness.py +0 -0
  133. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/equivalence/scenarios.py +0 -0
  134. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/equivalence/test_equivalence.py +0 -0
  135. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/equivalence/test_rust_timebase.py +0 -0
  136. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_backends.py +0 -0
  137. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_batch.py +0 -0
  138. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_benchmarks.py +0 -0
  139. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_cli.py +0 -0
  140. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_dsl.py +0 -0
  141. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_engine_ir.py +0 -0
  142. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_lang.py +0 -0
  143. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_model.py +0 -0
  144. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_ns3.py +0 -0
  145. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_profinet.py +0 -0
  146. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_semantics.py +0 -0
  147. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_simulation.py +0 -0
  148. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_stats.py +0 -0
  149. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_sweep.py +0 -0
  150. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_timebase.py +0 -0
  151. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/tests/test_validate.py +0 -0
  152. {smolpy-1.10.2.dev2 → smolpy-1.10.3.dev2}/uv.lock +0 -0
@@ -4,15 +4,19 @@ name: Docker image
4
4
  # the wheels of one version of smolpy and smolpy-engine-rs:
5
5
  # - <version>, latest: without ns-3, for linux/amd64 and linux/arm64;
6
6
  # - <version>-ns3, latest-ns3: on the ns-3 base image, with smol-ns3 built
7
- # in, for linux/amd64 (the base image's only platform so far).
7
+ # in, for linux/amd64 and linux/arm64. Each platform is built and tested
8
+ # on a runner of its own architecture, as smol-ns3 is compiled in the
9
+ # image; it is pushed as <version>-ns3-<arch>, and the two tags are the
10
+ # multi-platform index of both.
8
11
  # Every image is tested before anything is pushed: a .smol run through the
9
12
  # CLI; the wheel smoke test (bit-exact with SimPy) without ns-3, and the ns-3
10
13
  # suite with it.
11
14
  #
12
15
  # - Called by publish.yml at a release, once both packages are on PyPI: uses
13
16
  # the files of the same run and pushes both images.
14
- # - On a pull request that touches the images: builds the wheels here, for
15
- # linux/amd64 only, tests both images and pushes nothing.
17
+ # - On a pull request that touches the images: builds the wheels here, tests
18
+ # the image without ns-3 for linux/amd64 and the image with ns-3 for both
19
+ # platforms, and pushes nothing.
16
20
 
17
21
  on:
18
22
  pull_request:
@@ -96,6 +100,15 @@ jobs:
96
100
  manylinux: auto
97
101
  args: --release --out dist -m rust/smolpy-engine-rs/Cargo.toml
98
102
 
103
+ # for the ns-3 image on linux/arm64
104
+ - name: Build smolpy-engine-rs for aarch64
105
+ if: ${{ env.RELEASE != 'true' }}
106
+ uses: PyO3/maturin-action@v1
107
+ with:
108
+ target: aarch64
109
+ manylinux: auto
110
+ args: --release --out dist -m rust/smolpy-engine-rs/Cargo.toml
111
+
99
112
  # --- the image ---
100
113
 
101
114
  - name: Version
@@ -167,13 +180,20 @@ jobs:
167
180
  echo "Pushed $IMAGE:$VERSION and $IMAGE:latest" >> "$GITHUB_STEP_SUMMARY"
168
181
 
169
182
  image-ns3:
170
- name: ${{ inputs.version && format('Image {0}-ns3', inputs.version) || 'Image with ns-3 (test build)' }}
183
+ name: ${{ inputs.version && format('Image {0}-ns3', inputs.version) || 'Image with ns-3 (test build)' }}, ${{ matrix.platform }}
171
184
  needs: image
172
- runs-on: ubuntu-latest
185
+ runs-on: ${{ matrix.runner }}
173
186
  permissions:
174
187
  contents: read
175
188
  packages: write # push to ghcr.io
176
189
 
190
+ strategy:
191
+ fail-fast: false
192
+ matrix:
193
+ include:
194
+ - { platform: linux/amd64, arch: amd64, runner: ubuntu-latest }
195
+ - { platform: linux/arm64, arch: arm64, runner: ubuntu-24.04-arm }
196
+
177
197
  env:
178
198
  IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy
179
199
  RELEASE: ${{ inputs.version && 'true' || 'false' }}
@@ -196,13 +216,15 @@ jobs:
196
216
  # below that needed another build would fail
197
217
  - name: Build
198
218
  run: |
199
- docker buildx build --platform linux/amd64 --load \
219
+ docker buildx build --platform "${{ matrix.platform }}" --load \
200
220
  --build-arg VERSION="$VERSION" -f docker/Dockerfile.ns3 -t smolpy:test-ns3 .
221
+ docker image inspect --format '{{.Os}}/{{.Architecture}}' smolpy:test-ns3 \
222
+ | grep -qx "${{ matrix.platform }}"
201
223
  docker image ls smolpy:test-ns3
202
224
 
203
225
  - name: Test the CLI on ns-3
204
226
  run: |
205
- docker run --rm smolpy:test-ns3 --help
227
+ docker run --rm smolpy:test-ns3 --version | grep -qx "smolpy $VERSION"
206
228
  mkdir -p out && chmod 777 out
207
229
  cp docker/smoke.smol out/
208
230
  docker run --rm -v "$PWD/out:/work" \
@@ -230,8 +252,38 @@ jobs:
230
252
  - name: Push
231
253
  if: ${{ env.RELEASE == 'true' }}
232
254
  run: |
233
- for tag in "$VERSION-ns3" latest-ns3; do
234
- docker tag smolpy:test-ns3 "$IMAGE:$tag"
235
- docker push "$IMAGE:$tag"
236
- done
237
- echo "Pushed $IMAGE:$VERSION-ns3 and $IMAGE:latest-ns3" >> "$GITHUB_STEP_SUMMARY"
255
+ docker tag smolpy:test-ns3 "$IMAGE:$VERSION-ns3-${{ matrix.arch }}"
256
+ docker push "$IMAGE:$VERSION-ns3-${{ matrix.arch }}"
257
+ echo "Pushed $IMAGE:$VERSION-ns3-${{ matrix.arch }}" >> "$GITHUB_STEP_SUMMARY"
258
+
259
+ # <version>-ns3 and latest-ns3: one tag for both platforms, from the images
260
+ # tested above
261
+ image-ns3-index:
262
+ name: ${{ inputs.version && format('Image {0}-ns3, both platforms', inputs.version) || 'Image with ns-3, both platforms (release only)' }}
263
+ needs: [image, image-ns3]
264
+ if: ${{ inputs.version }}
265
+ runs-on: ubuntu-latest
266
+ permissions:
267
+ contents: read
268
+ packages: write # push to ghcr.io
269
+
270
+ env:
271
+ IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy
272
+ VERSION: ${{ needs.image.outputs.version }}
273
+
274
+ steps:
275
+ - uses: docker/setup-buildx-action@v3
276
+
277
+ - name: Log in to ghcr.io
278
+ uses: docker/login-action@v3
279
+ with:
280
+ registry: ghcr.io
281
+ username: ${{ github.actor }}
282
+ password: ${{ secrets.GITHUB_TOKEN }}
283
+
284
+ - name: Push the index
285
+ run: |
286
+ docker buildx imagetools create -t "$IMAGE:$VERSION-ns3" -t "$IMAGE:latest-ns3" \
287
+ "$IMAGE:$VERSION-ns3-amd64" "$IMAGE:$VERSION-ns3-arm64"
288
+ docker buildx imagetools inspect "$IMAGE:$VERSION-ns3"
289
+ echo "Pushed $IMAGE:$VERSION-ns3 and $IMAGE:latest-ns3 for linux/amd64 and linux/arm64" >> "$GITHUB_STEP_SUMMARY"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: smolpy
3
- Version: 1.10.2.dev2
3
+ Version: 1.10.3.dev2
4
4
  Summary: Network simulation DSL and discrete-event simulator
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -39,16 +39,17 @@ Python rewrite of SMOL — a Network Description Language and Discrete-Event Sim
39
39
 
40
40
  SMOLPy lets you describe a network topology in pure Python, define traffic flows, and run a discrete-event simulation that produces real metric time-series. A built-in Dear PyGui desktop dashboard shows the topology and live metric charts as the simulation runs.
41
41
 
42
- > **Two simulation engines, one model.** SMOLPy is no longer a SimPy-only simulator. A scenario, written in Python or in a `.smol` file, becomes one execution-independent model, and it can run on more than one engine:
42
+ > **Three simulation engines, one model.** A scenario, written in Python or in a `.smol` file, becomes one execution-independent model, and it runs on any of three engines:
43
43
  >
44
44
  > - **SimPy** (Python): the reference implementation. It is always installed, runs the whole model and drives the dashboards.
45
45
  > - **Rust** (`smol-engine`): a native engine that gives **SimPy's results bit for bit** and runs about **40× faster**. B1 at 10 M frames takes 4.9 s, against 200.8 s on SimPy.
46
+ > - **ns-3**: the same scenario on **[ns-3](https://www.nsnam.org/)**, the established network simulator, with its real IPv4, UDP and **TCP** stack. Modbus TCP and MQTT run over ns-3's TCP, with its handshake, acknowledgements, and flow and congestion control. Ethernet and PROFINET RT give SimPy's results bit for bit.
46
47
  >
47
48
  > ```python
48
- > result = net.simulate(duration=60_000, backend="rust")
49
+ > result = net.simulate(duration=60_000, backend="rust") # or "ns3"
49
50
  > ```
50
51
  >
51
- > The Rust engine runs the whole model: Ethernet, Modbus TCP, MQTT and PROFINET RT. Only the live and text dashboards need SimPy. See [Simulation engine](#simulation-engine) and [ADR-0008](https://jwszolek.github.io/SMOLPy/adr/0008-rust-des-engine-mvp/).
52
+ > Every engine runs the whole model: Ethernet, Modbus TCP, MQTT and PROFINET RT. Only the live and text dashboards need SimPy. See [Simulation engine](#simulation-engine), [Running on ns-3](#running-on-ns-3) and [Execution backends](https://jwszolek.github.io/SMOLPy/backends/).
52
53
 
53
54
  📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
54
55
 
@@ -99,7 +100,7 @@ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend
99
100
  - It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
100
101
  - A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
101
102
 
102
- **With ns-3,** from the image `<version>-ns3` or `latest-ns3`, for `linux/amd64`, published from 1.10.0 on. It adds the pinned ns-3 build and the ns-3 backend, ready to run:
103
+ **With ns-3,** from the image `<version>-ns3` or `latest-ns3`, published from 1.10.0 on, for `linux/amd64` and, from the release after 1.10.1, `linux/arm64`. It adds the pinned ns-3 build and the ns-3 backend, ready to run:
103
104
 
104
105
  ```bash
105
106
  docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
@@ -483,7 +484,7 @@ IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyc
483
484
 
484
485
  ## Simulation engine
485
486
 
486
- Every simulation goes through the same path. The Python API and `.smol` files build a **Scenario IR**, an execution-independent model ([ADR-0007](https://jwszolek.github.io/SMOLPy/adr/0007-execution-independent-scenario-model/)), and a **backend** runs it. Both engines follow the same written contract, [Model Semantics](https://jwszolek.github.io/SMOLPy/model-semantics/):
487
+ Every simulation goes through the same path. The Python API and `.smol` files build a **Scenario IR**, an execution-independent model ([ADR-0007](https://jwszolek.github.io/SMOLPy/adr/0007-execution-independent-scenario-model/)), and a **backend** runs it. Every engine follows the same written contract, [Model Semantics](https://jwszolek.github.io/SMOLPy/model-semantics/):
487
488
  - simulated time is integer nanoseconds;
488
489
  - frames are modelled on the wire as real Ethernet, with preamble, FCS and inter-frame gap.
489
490
 
@@ -502,11 +503,11 @@ batch = run_many(net, runs=30, duration=60_000, backend="rust")
502
503
  smolpy run plant.smol --backend rust
503
504
  ```
504
505
 
505
- - **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses each engine's own generator, so there the results agree statistically. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
506
+ - **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses its own generator, so there the results agree statistically. ns-3 draws random traffic from SimPy's streams, so its Ethernet and PROFINET RT results are bit for bit with the same seed, random traffic included. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
506
507
  - **ns-3 adds TCP.** Ethernet and PROFINET on ns-3 also give SimPy's results bit for bit. Modbus and MQTT run over ns-3's TCP, so their results differ by what TCP does: under heavy load by up to +43 % in latency. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/) has the details and measurements.
507
508
  - **Nothing is skipped silently.** A scenario that uses something a backend does not support is rejected before the run with a message naming the element. Asking the Rust engine for a dashboard is an error too.
508
509
 
509
- The model both engines implement:
510
+ The model every engine implements:
510
511
 
511
512
  - **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.
512
513
  - **Store-and-forward model** — transmission delay + propagation delay per hop.
@@ -516,6 +517,35 @@ The model both engines implement:
516
517
 
517
518
  ---
518
519
 
520
+ ## Running on ns-3
521
+
522
+ The `ns3` backend runs a SMOL scenario on [ns-3](https://www.nsnam.org/) 3.49, the open-source network simulator used widely in networking research. The same `.smol` file or `Network` that runs on SimPy runs there too, unchanged:
523
+
524
+ ```bash
525
+ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
526
+ ```
527
+
528
+ ```python
529
+ result = net.simulate(duration=60_000, backend="ns3")
530
+ ```
531
+
532
+ **What it is for.**
533
+ - **A real TCP.** SMOL sizes Modbus TCP and MQTT frames as TCP segments, but SimPy and Rust do not model TCP's behaviour. On ns-3 every Modbus master–slave and MQTT client–broker pair has one persistent connection over ns-3's TCP: the handshake, delayed acknowledgements, CUBIC congestion control and the receiver's window.
534
+ - **A cross-check against an established simulator.** Below the TCP layer, ns-3 runs SMOL's own full-duplex Ethernet device and switch. So Ethernet over UDP and PROFINET RT on layer 2 give SimPy's results **bit for bit**, watchdog expiries and stochastic traffic included. That ties SMOL's reference model to ns-3's event scheduler and IP stack.
535
+ - **Where TCP matters.** `python -m benchmarks load` runs a plant cell whose Modbus and MQTT traffic shares a 10 Mb/s uplink with a UDP camera, from 50 % to 150 % offered load:
536
+
537
+ | Offered load | Modbus RTT, SimPy → ns-3 | MQTT latency, SimPy → ns-3 | Delivered to the HMI |
538
+ |---|---|---|---|
539
+ | 0.50 – 0.95 | within 0.4 % | within 0.4 % | the same |
540
+ | 1.00 | +18 % | +25 % | the same |
541
+ | 1.50 | 3.2 → 3.4 s (+6 %) | 3.2 → 4.5 s (+43 %) | −41 % |
542
+
543
+ Below saturation the engines agree. At saturation, TCP's own acknowledgements tip the link over. Heavily overloaded, TCP's windows hold MQTT back while the UDP stream, which does not back off, takes the link. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/#modbus-and-mqtt-over-tcp) has the full table and the mechanism.
544
+
545
+ **Getting it.** ns-3 cannot be installed with `pip`, so the simplest way is the image `ghcr.io/jwszolek/smolpy:latest-ns3` ([Install](#install)). It holds the ns-3 build, SMOLPy, the Rust engine and `smol-ns3`, the C++ program that runs scenarios on ns-3, compiled in. With your own ns-3 3.49 build instead, set `NS3_HOME` to it: the first run compiles `smol-ns3` in about 8 s and caches it.
546
+
547
+ ---
548
+
519
549
  ## Examples
520
550
 
521
551
  See [`examples/README.md`](examples/README.md) for ten ready-to-run scenarios covering single-switch saturation, oversubscription, two-tier access bottlenecks, MQTT publish-subscribe, Modbus TCP polling, and PROFINET RT cyclic I/O.
@@ -11,16 +11,17 @@ Python rewrite of SMOL — a Network Description Language and Discrete-Event Sim
11
11
 
12
12
  SMOLPy lets you describe a network topology in pure Python, define traffic flows, and run a discrete-event simulation that produces real metric time-series. A built-in Dear PyGui desktop dashboard shows the topology and live metric charts as the simulation runs.
13
13
 
14
- > **Two simulation engines, one model.** SMOLPy is no longer a SimPy-only simulator. A scenario, written in Python or in a `.smol` file, becomes one execution-independent model, and it can run on more than one engine:
14
+ > **Three simulation engines, one model.** A scenario, written in Python or in a `.smol` file, becomes one execution-independent model, and it runs on any of three engines:
15
15
  >
16
16
  > - **SimPy** (Python): the reference implementation. It is always installed, runs the whole model and drives the dashboards.
17
17
  > - **Rust** (`smol-engine`): a native engine that gives **SimPy's results bit for bit** and runs about **40× faster**. B1 at 10 M frames takes 4.9 s, against 200.8 s on SimPy.
18
+ > - **ns-3**: the same scenario on **[ns-3](https://www.nsnam.org/)**, the established network simulator, with its real IPv4, UDP and **TCP** stack. Modbus TCP and MQTT run over ns-3's TCP, with its handshake, acknowledgements, and flow and congestion control. Ethernet and PROFINET RT give SimPy's results bit for bit.
18
19
  >
19
20
  > ```python
20
- > result = net.simulate(duration=60_000, backend="rust")
21
+ > result = net.simulate(duration=60_000, backend="rust") # or "ns3"
21
22
  > ```
22
23
  >
23
- > The Rust engine runs the whole model: Ethernet, Modbus TCP, MQTT and PROFINET RT. Only the live and text dashboards need SimPy. See [Simulation engine](#simulation-engine) and [ADR-0008](https://jwszolek.github.io/SMOLPy/adr/0008-rust-des-engine-mvp/).
24
+ > Every engine runs the whole model: Ethernet, Modbus TCP, MQTT and PROFINET RT. Only the live and text dashboards need SimPy. See [Simulation engine](#simulation-engine), [Running on ns-3](#running-on-ns-3) and [Execution backends](https://jwszolek.github.io/SMOLPy/backends/).
24
25
 
25
26
  📖 **Full documentation:** [jwszolek.github.io/SMOLPy](https://jwszolek.github.io/SMOLPy/)
26
27
 
@@ -71,7 +72,7 @@ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend
71
72
  - It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
72
73
  - A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
73
74
 
74
- **With ns-3,** from the image `<version>-ns3` or `latest-ns3`, for `linux/amd64`, published from 1.10.0 on. It adds the pinned ns-3 build and the ns-3 backend, ready to run:
75
+ **With ns-3,** from the image `<version>-ns3` or `latest-ns3`, published from 1.10.0 on, for `linux/amd64` and, from the release after 1.10.1, `linux/arm64`. It adds the pinned ns-3 build and the ns-3 backend, ready to run:
75
76
 
76
77
  ```bash
77
78
  docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
@@ -455,7 +456,7 @@ IRT (isochronous, scheduled) traffic, AR establishment (DCP / RPC connect), acyc
455
456
 
456
457
  ## Simulation engine
457
458
 
458
- Every simulation goes through the same path. The Python API and `.smol` files build a **Scenario IR**, an execution-independent model ([ADR-0007](https://jwszolek.github.io/SMOLPy/adr/0007-execution-independent-scenario-model/)), and a **backend** runs it. Both engines follow the same written contract, [Model Semantics](https://jwszolek.github.io/SMOLPy/model-semantics/):
459
+ Every simulation goes through the same path. The Python API and `.smol` files build a **Scenario IR**, an execution-independent model ([ADR-0007](https://jwszolek.github.io/SMOLPy/adr/0007-execution-independent-scenario-model/)), and a **backend** runs it. Every engine follows the same written contract, [Model Semantics](https://jwszolek.github.io/SMOLPy/model-semantics/):
459
460
  - simulated time is integer nanoseconds;
460
461
  - frames are modelled on the wire as real Ethernet, with preamble, FCS and inter-frame gap.
461
462
 
@@ -474,11 +475,11 @@ batch = run_many(net, runs=30, duration=60_000, backend="rust")
474
475
  smolpy run plant.smol --backend rust
475
476
  ```
476
477
 
477
- - **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses each engine's own generator, so there the results agree statistically. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
478
+ - **The same numbers.** On deterministic scenarios the Rust engine reproduces SimPy's results bit for bit, down to the event count. Random traffic uses its own generator, so there the results agree statistically. ns-3 draws random traffic from SimPy's streams, so its Ethernet and PROFINET RT results are bit for bit with the same seed, random traffic included. CI checks both on every pull request ([ADR-0009](https://jwszolek.github.io/SMOLPy/adr/0009-batch-execution-and-cross-backend-validation/)).
478
479
  - **ns-3 adds TCP.** Ethernet and PROFINET on ns-3 also give SimPy's results bit for bit. Modbus and MQTT run over ns-3's TCP, so their results differ by what TCP does: under heavy load by up to +43 % in latency. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/) has the details and measurements.
479
480
  - **Nothing is skipped silently.** A scenario that uses something a backend does not support is rejected before the run with a message naming the element. Asking the Rust engine for a dashboard is an error too.
480
481
 
481
- The model both engines implement:
482
+ The model every engine implements:
482
483
 
483
484
  - **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.
484
485
  - **Store-and-forward model** — transmission delay + propagation delay per hop.
@@ -488,6 +489,35 @@ The model both engines implement:
488
489
 
489
490
  ---
490
491
 
492
+ ## Running on ns-3
493
+
494
+ The `ns3` backend runs a SMOL scenario on [ns-3](https://www.nsnam.org/) 3.49, the open-source network simulator used widely in networking research. The same `.smol` file or `Network` that runs on SimPy runs there too, unchanged:
495
+
496
+ ```bash
497
+ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
498
+ ```
499
+
500
+ ```python
501
+ result = net.simulate(duration=60_000, backend="ns3")
502
+ ```
503
+
504
+ **What it is for.**
505
+ - **A real TCP.** SMOL sizes Modbus TCP and MQTT frames as TCP segments, but SimPy and Rust do not model TCP's behaviour. On ns-3 every Modbus master–slave and MQTT client–broker pair has one persistent connection over ns-3's TCP: the handshake, delayed acknowledgements, CUBIC congestion control and the receiver's window.
506
+ - **A cross-check against an established simulator.** Below the TCP layer, ns-3 runs SMOL's own full-duplex Ethernet device and switch. So Ethernet over UDP and PROFINET RT on layer 2 give SimPy's results **bit for bit**, watchdog expiries and stochastic traffic included. That ties SMOL's reference model to ns-3's event scheduler and IP stack.
507
+ - **Where TCP matters.** `python -m benchmarks load` runs a plant cell whose Modbus and MQTT traffic shares a 10 Mb/s uplink with a UDP camera, from 50 % to 150 % offered load:
508
+
509
+ | Offered load | Modbus RTT, SimPy → ns-3 | MQTT latency, SimPy → ns-3 | Delivered to the HMI |
510
+ |---|---|---|---|
511
+ | 0.50 – 0.95 | within 0.4 % | within 0.4 % | the same |
512
+ | 1.00 | +18 % | +25 % | the same |
513
+ | 1.50 | 3.2 → 3.4 s (+6 %) | 3.2 → 4.5 s (+43 %) | −41 % |
514
+
515
+ Below saturation the engines agree. At saturation, TCP's own acknowledgements tip the link over. Heavily overloaded, TCP's windows hold MQTT back while the UDP stream, which does not back off, takes the link. [Execution backends](https://jwszolek.github.io/SMOLPy/backends/#modbus-and-mqtt-over-tcp) has the full table and the mechanism.
516
+
517
+ **Getting it.** ns-3 cannot be installed with `pip`, so the simplest way is the image `ghcr.io/jwszolek/smolpy:latest-ns3` ([Install](#install)). It holds the ns-3 build, SMOLPy, the Rust engine and `smol-ns3`, the C++ program that runs scenarios on ns-3, compiled in. With your own ns-3 3.49 build instead, set `NS3_HOME` to it: the first run compiles `smol-ns3` in about 8 s and caches it.
518
+
519
+ ---
520
+
491
521
  ## Examples
492
522
 
493
523
  See [`examples/README.md`](examples/README.md) for ten ready-to-run scenarios covering single-switch saturation, oversubscription, two-tier access bottlenecks, MQTT publish-subscribe, Modbus TCP polling, and PROFINET RT cyclic I/O.
@@ -183,7 +183,7 @@ ns-3 is the one backend that cannot be installed with `pip`. It is a C++ code ba
183
183
 
184
184
  *As built (2026-11-16):* the image without ns-3 is `docker/Dockerfile`, built by `.github/workflows/docker-image.yml`. Each release, `publish.yml` calls it once both packages are on PyPI. It tests the image of each platform with the wheel smoke test and a `.smol` run through the CLI before it pushes `<version>` and `latest`. A pull request that changes the image builds and tests it for `linux/amd64` and pushes nothing. The image runs as uid 1000, not as root.
185
185
 
186
- *As built (2026-11-16):* the image with ns-3 is `docker/Dockerfile.ns3`, built by a second job of the same workflow, for `linux/amd64`:
186
+ *As built (2026-11-16):* the image with ns-3 is `docker/Dockerfile.ns3`, built by a second job of the same workflow, for `linux/amd64` and (*as built, 2026-11-17*) `linux/arm64`. Each platform is built and tested on a runner of its own architecture, since `smol-ns3` is compiled in the image, and pushed as `<version>-ns3-amd64` and `-arm64`; `<version>-ns3` and `latest-ns3` are the index of both:
187
187
  - **Contents.** The base image `smolpy-ns3-base:3.49`, plus `smolpy` and `smolpy-engine-rs` from the same wheels as the image without ns-3.
188
188
  - **`smol-ns3` built in.** It is built once, in the image, into a cache that every user reads (`XDG_CACHE_HOME=/opt/smolpy/cache`). No run compiles it. The cache is read-only, so a run that would need another build, for example with another `CXX`, fails instead of building one. Its message says to set `XDG_CACHE_HOME` to a writable directory, where the build then takes about 8 s.
189
189
  - **Tests.** Before the image is pushed, CI runs `docker/smoke.smol`, with every protocol, on ns-3 through the CLI as uid 1000. It also runs the ns-3 suite of the same commit against the SMOLPy installed in the image.
@@ -0,0 +1,198 @@
1
+ # ADR-0011: Bounded Switch Buffers with Frame Loss
2
+
3
+ **Status:** Proposed
4
+ **Date:** 2026-11-23
5
+ **Amends:** ADR-0007 (a new optional field of the IR, which stays version 2), ADR-0004 (the `smol-ns3` line format becomes version 2), [Model Semantics](../model-semantics.md) §3, §5, §8 and §9
6
+ **Roadmap:** the candidate "Bounded switch buffers with frame loss"
7
+
8
+ ---
9
+
10
+ ## Context
11
+
12
+ Model Semantics §3 says: *"Queues are unbounded, so no frame is ever dropped for lack of buffer."* Below saturation that costs nothing. Near saturation and above it, it is where the model and a real network part ways.
13
+
14
+ **A hardware testbed shows where.** The setup:
15
+ - **Switch:** a TP-Link LS108GP, an unmanaged 8 × 1 Gb/s store-and-forward switch.
16
+ - **Traffic:** a Raspberry Pi on a 1 Gb/s port sends Poisson UDP traffic, 1 518 B frames, to a laptop whose port runs at 100 Mb/s.
17
+ - **Polling:** the laptop polls a Modbus TCP server on the Pi every 10 ms. The responses share the laptop's egress port with the UDP stream.
18
+
19
+ | Offered load ρ of the 100 Mb/s port | Measured | SMOLPy (unbounded queues) |
20
+ |---|---|---|
21
+ | up to 0.93 | Modbus RTT: mean wait, median, p90, p99 | the same, within a few percent |
22
+ | 0.996 | RTT capped at about 9.8 ms; 0.09 % of UDP frames lost | median 11 ms, p99 79 ms, nothing lost |
23
+
24
+ The cap and the loss point to a bounded egress buffer of about 115 kB, or about 75 frames of 1 538 B on the wire: 75 × 1 538 × 8 / 100 Mb/s = 9.2 ms. An unbounded queue at ρ ≈ 1 grows without limit, and so does the delay it predicts.
25
+
26
+ The same limitation appears in the ns-3 load study ([Execution backends](../backends.md#modbus-and-mqtt-over-tcp)). There nothing is dropped, so ns-3's TCP never retransmits, and its overload behaviour comes only from its windows.
27
+
28
+ ### Options considered
29
+
30
+ - **A — keep unbounded queues** and document the limit of validity. Cheap, but the model then cannot be used at and above saturation, which is where industrial networks are dimensioned.
31
+ - **B — a bounded egress buffer per switch port, with tail drop.** **Chosen.** It is what the unmanaged switches of the testbed do. It needs one new scenario parameter, and every engine can reproduce it exactly.
32
+ - **C — a shared buffer pool per switch with dynamic thresholds**, as managed switches have. Closer to some hardware, but the sharing policy is vendor-specific and has no single correct model. It stays a possible later extension of B (below).
33
+ - **D — active queue management (RED, CoDel).** Not what industrial unmanaged switches do. Out of scope.
34
+
35
+ ---
36
+
37
+ ## Decision
38
+
39
+ ### The parameter
40
+
41
+ A switch takes an optional **egress buffer limit in bytes**, the same for each of its ports:
42
+
43
+ ```
44
+ switch sw ports=8 buffer=115000
45
+ switch sw ports=8 buffer=115kB # 115 000 B
46
+ switch sw ports=8 buffer=112KiB # 114 688 B
47
+ ```
48
+
49
+ ```python
50
+ sw = net.switch("sw", ports=8, buffer=115_000)
51
+ ```
52
+
53
+ - **Unit: bytes.** Real switches allocate buffer memory by size, not by frame count. A limit in frames would let 64 B and 1 518 B frames take the same space.
54
+ - **Suffixes** in `.smol`: `kB` (10³), `MB` (10⁶), `KiB` (2¹⁰), `MiB` (2²⁰). The value must come out as a whole number of bytes. The Python API takes an `int`.
55
+ - **Default: unbounded,** as now. A scenario without `buffer` means exactly what it meant before: same results, same event counts, same benchmark hashes (B1–B4) and the same equivalence suite.
56
+ - **Validation.** `buffer` must be a positive integer, not a bool. It must be at least one maximum frame: 1 522 B, the largest standard frame with an 802.1Q tag, and at least the largest frame that any traffic statement of the scenario sends. A jumbo flow would otherwise be dropped in full at every bounded switch it crosses.
57
+ - **IR.** `SwitchNode.buffer_bytes: int | None = None`, `None` meaning unbounded.
58
+
59
+ ### What occupies the buffer
60
+
61
+ - **Frame bytes.** A frame occupies its size as defined in Model Semantics §2: header to FCS, its 802.1Q tag included, without the preamble, SFD or gap. That is how switches account buffer memory, and how `bytes_sent` and `bytes_received` already count.
62
+ - **Only waiting frames.** The buffer holds exactly the frames that `queue_depth` counts: those queued on the port and not yet taken by its transmitter. **The frame in transmission does not occupy the buffer.**
63
+ - It has left the queue: one notion of "queued" serves both `queue_depth` and the limit.
64
+ - The delay a frame can see is then bounded simply: what is queued ahead of it, plus at most one frame in transmission (below).
65
+ - A real switch also holds the frame it is sending, so its memory is `buffer` plus one frame per port. For the testbed that is one frame in 76, or 1.3 %: `buffer` is the switch's memory less one maximum frame.
66
+ - **When the transmitter takes a frame.** This is today's behaviour, now stated, because the limit makes it observable:
67
+ - when the transmitter has sent a frame's FCS, it takes the next frame at once, if there is one. That frame then waits out the inter-frame gap as part of its own transmission (§3);
68
+ - when the transmitter is idle, it takes a frame queued at instant `t` at the same instant, **after the events already scheduled for `t`** (§9). Frames queued in between at `t` are in the buffer together, and the transmitter takes the highest-priority one of them.
69
+
70
+ ### Admission: tail drop
71
+
72
+ A frame of size `s` that arrives at a port with `q` bytes queued:
73
+ - is **queued** if `q + s ≤ buffer`;
74
+ - is **dropped** otherwise. It is never queued, and nothing else changes: no queued frame is displaced, and the transmitter does not notice.
75
+
76
+ Further rules:
77
+ - **Priorities.** One limit per port is shared by all 8 priority classes. The arriving frame is dropped whatever its priority. A PROFINET frame (PCP 6) that arrives at a port full of best-effort frames is lost. That is what a single-buffer unmanaged switch does. With `qos="fifo"` there is one class, and nothing else changes.
78
+ - **Flooding.** Each copy of a flooded frame is admitted or dropped on its own port.
79
+ - **Simultaneous arrivals.** Admissions at the same instant are decided in the order the frames are queued (§9). That is the order in which the switch forwards them, and within one forward, port order for flooded copies. Together with the rule on when the transmitter takes a frame, every engine decides every drop the same way.
80
+ - **Bound on delay.** A frame admitted with `n` frames of `q ≤ buffer − s` bytes ahead of it waits at most `tx(q + 20·n) + tx(8 + m) + tx(12)` before its own preamble starts. Here `m` is the largest frame in the scenario, for the frame in transmission and its gap. Its queueing delay is therefore at most about `buffer / speed` plus one frame time.
81
+
82
+ ### Scope
83
+
84
+ - **Per egress port of a switch.** Ingress buffering is not modelled. A switch forwards in zero time (§4).
85
+ - **End stations stay unbounded.** The egress queues of adapters, MQTT brokers, Modbus slaves and PROFINET devices have no limit. A station never drops a frame it generates, as a host's socket buffer and qdisc would push back on the application instead. The scenario offers its traffic, and only the network loses it.
86
+ - **Possible later extensions, not part of this decision:**
87
+ - a buffer pool shared by the ports of a switch, with per-port thresholds;
88
+ - limits per priority class;
89
+ - a limit in frames, for switches that count descriptors.
90
+
91
+ ### Protocols when a frame is lost
92
+
93
+ **On SimPy and Rust there is no transport layer.** SMOL sizes Modbus TCP and MQTT frames as TCP segments but models no TCP behaviour, so nothing is retransmitted:
94
+ - **Modbus TCP:** a lost request or response leaves its poll without a response. The master does not retry, and its next polls go out on schedule.
95
+ - **MQTT:**
96
+ - a lost PUBLISH is lost: the broker forwards nothing and sends no PUBACK;
97
+ - a lost forwarded copy is lost to that subscriber;
98
+ - a lost PUBACK changes nothing, since publishers do not wait for it.
99
+ - **PROFINET RT:** there is no retransmission in PROFINET RT either. A lost cyclic frame leaves a gap. If no frame arrives within `hold × cycle`, the watchdog expires (§7), as on a real device.
100
+ - **Flows (UDP-like):** lost.
101
+
102
+ **This is a limitation, and it is stated as one.** A real Modbus TCP or MQTT stack retransmits a lost segment, after a retransmission timeout or three duplicate acknowledgements. So the message arrives late rather than not at all, and the connection's window shrinks. **The ns-3 backend shows that behaviour.** There Modbus and MQTT run over ns-3's TCP (CUBIC, minimum RTO 1 s, fast retransmit), and a dropped segment is retransmitted. The engines therefore disagree by design on these protocols under loss: SimPy and Rust count a lost poll, while ns-3 delivers it late and shows the delay in `modbus_latency`. That difference is measured (below), not hidden.
103
+
104
+ ### Metrics
105
+
106
+ | Metric | On | Value at a sample | Unit |
107
+ |---|---|---|---|
108
+ | `drops` | switch | frames its egress buffers dropped in the window. Sampled every time, 0 included. | frames |
109
+ | `drops_total` | switch | frames its egress buffers dropped so far | frames |
110
+ | `frames_sent` | adapter | frames whose transmission on the adapter's link has completed so far, as `bytes_sent` | frames |
111
+ | `frames_received` | adapter | frames the adapter has accepted so far, as `bytes_received` | frames |
112
+ | `modbus_unanswered` | adapter | Modbus requests the adapter has generated so far, less the responses it has accepted so far: lost polls plus polls in flight | polls |
113
+
114
+ - **Loss of a flow.** For a flow `a → b`, when `a` sends nothing else: lost = `frames_sent:a` − `frames_received:b`, less the frames in flight at the sample. That is at most the frames buffered on the path. Over a long run the loss ratio is `1 − frames_received:b / frames_sent:a`.
115
+ - **Lost polls.** `modbus_unanswered` includes polls still in flight. That is at most `⌈max RTT / poll period⌉` per poll statement, and with bounded buffers the RTT is bounded. It is a count, not a ratio: the requests generated are `rate × t`.
116
+ - **All counts are integers** and are reported as they are, like `pn_watchdog_expiries`.
117
+ - **Why not count losses per destination at the switch?** A flooded frame's copy that is dropped on a port leading away from its destination is not a loss to anyone, and the switch cannot tell which copy that is. Counts at the end stations are exact.
118
+
119
+ ### The IR stays version 2
120
+
121
+ - **New field:** `SwitchNode.buffer_bytes`, optional.
122
+ - **No new version.** By ADR-0007's rule, a new optional field does not change the version, and only a change in meaning does. A switch without the field means what it always meant.
123
+ - **Nothing is run without it.** Every reader rejects fields it does not know. An engine that predates this ADR therefore rejects a document with a bounded switch instead of running it as lossless. Before that, `check()` rejects the scenario for the missing capability (below).
124
+ - **Written only when set.** `buffer_bytes` is left out of the JSON while it is `None`, so a document without bounded switches is byte for byte what it was before, and older readers still read it.
125
+ - **The Rust package.** `smolpy[rust]` requires the `smolpy-engine-rs` release that runs bounded switches.
126
+
127
+ ### Capabilities
128
+
129
+ A new capability feature, `"bounded_buffer"`. `smolpy.backends.check` rejects a scenario with a bounded switch on a backend without it, naming the switch, before the run. A backend never ignores `buffer` silently. The new metrics are capabilities as usual. All three backends get the feature in this change.
130
+
131
+ ### ns-3
132
+
133
+ The ns-3 backend does not use ns-3 queues for switches. Links and switches are SMOL's own (`SmolDevice`, `SmolSwitch` in `smol-ns3.cc`). So:
134
+ - **The limit** is implemented in `SmolDevice::Enqueue`, with a byte count of the queued frames and a drop counter. The `switch` line carries the limit: `switch <buffer bytes>`, 0 for unbounded.
135
+ - **The idle-port rule above.** `SmolDevice` today starts the first frame queued on an idle port at once, while SimPy and Rust take it after the events already scheduled for that instant. That difference was not observable so far, apart from a same-instant priority order no test covered. It is now, so `SmolDevice` defers the start with `Simulator::ScheduleNow`, which ns-3 orders FIFO among same-instant events, as SimPy does.
136
+ - **Format.** The line format becomes `smol-ns3 2`, and the observe kinds `drops`, `frames_sent`, `frames_received` and `modbus_unanswered` are added.
137
+ - **Expected agreement:**
138
+ - Ethernet over UDP and PROFINET RT stay bit-exact with SimPy, drops included, stochastic scenarios with the same seed included;
139
+ - Modbus and MQTT differ by TCP, as now, and now also by its retransmissions.
140
+
141
+ ### Validation and tests
142
+
143
+ - **Unit tests:**
144
+ - validation of `buffer`;
145
+ - no drops while the limit is never reached;
146
+ - a drop exactly when `q + s > buffer`, for each class and for flooded copies;
147
+ - same-instant arrivals at a full queue;
148
+ - delay within the bound above;
149
+ - `drops_total` = `frames_sent` − `frames_received` − in flight, for one flow.
150
+ - **Analytical test.** One egress port with Poisson arrivals of fixed-size frames is an M/D/1/K queue:
151
+ - service time `D = tx(8 + s) + tx(12)`;
152
+ - `K = 1 + ⌊buffer / s⌋`: the frame in transmission and the waiting room.
153
+
154
+ Its blocking probability and mean waiting time come from the embedded Markov chain at departures. They are compared with `drops_total` / `frames_sent` and with the mean latency, over several seeds, with a tolerance from the spread across seeds. The model differs from M/D/1/K only for the first frame of a busy period, whose remaining gap is shorter than `tx(12)`. The test uses 9 000 B frames, where that is under 0.14 % of `D`.
155
+ - **Cross-engine:**
156
+ - deterministic scenarios with drops, same-instant arrivals at a full queue among them, go into the bit-exact set of SimPy and Rust, event counts included;
157
+ - the same Ethernet and PROFINET scenarios are compared exactly on ns-3.
158
+ - **The testbed scenario.** Poisson UDP of 1 518 B frames and Modbus polls every 10 ms share a 100 Mb/s port with `buffer=115000`, at ρ from 0.9 to 1.05. It runs on all three engines. The report covers the Modbus RTT (mean, median, p99, maximum), lost polls on SimPy and Rust against late polls on ns-3, and the UDP loss ratio, set against the testbed: 9.8 ms and 0.09 % at ρ = 0.996.
159
+
160
+ ### Steps
161
+
162
+ 1. **The model.**
163
+ - the optional IR field, written only when set;
164
+ - `buffer` in the Python API and in `.smol`, with its suffixes;
165
+ - validation;
166
+ - the capability feature, which no backend has yet, so every backend rejects a bounded switch.
167
+ 2. **SimPy:**
168
+ - the limit, the drops and the five metrics;
169
+ - unit, semantics and M/D/1/K tests;
170
+ - Model Semantics updated.
171
+ 3. **Rust:**
172
+ - the same;
173
+ - the bit-exact scenarios with drops;
174
+ - the `smolpy-engine-rs` floor raised.
175
+ 4. **ns-3:**
176
+ - format 2, the limit and the counters, the deferred start on an idle port;
177
+ - the exact comparisons;
178
+ - the testbed scenario on all three engines, with its results recorded.
179
+ 5. **Documentation:**
180
+ - language reference, DSL reference, backends;
181
+ - an example scenario: a 100 Mb/s bottleneck with `buffer=115000` near ρ = 1;
182
+ - the roadmap item moved to done.
183
+
184
+ ---
185
+
186
+ ## Consequences
187
+
188
+ **Positive**
189
+ - **The model can be used at and above saturation.** Delay is capped by the buffer, and loss appears where it does on real switches.
190
+ - **The testbed's knee is reproducible:** capped RTT and the onset of loss at ρ ≈ 1.
191
+ - **All three engines implement the same rule exactly,** so SimPy and Rust stay bit-exact and ns-3 stays bit-exact on Ethernet and PROFINET.
192
+ - **ns-3's TCP can now be studied under loss,** with retransmissions, which the previous load study could not show.
193
+
194
+ **Negative / trade-offs**
195
+ - **A new `smolpy-engine-rs` release.** `smolpy[rust]` needs the engine that runs bounded switches.
196
+ - **On SimPy and Rust, Modbus and MQTT simply lose messages,** where a real stack retransmits them. Results for these protocols under loss are a lower bound on delivery and say nothing about retransmission delay. ns-3 is the backend for that.
197
+ - **One limit per port, shared by all priorities.** Switches that reserve buffer for high priorities, or share a pool across ports, are not modelled yet.
198
+ - **The idle-port rule is now normative.** It was an implementation detail of SimPy, and ns-3 is changed to follow it.
@@ -32,7 +32,7 @@ A scenario outside a backend's capabilities is rejected before it runs, with the
32
32
 
33
33
  ## Installing ns-3
34
34
 
35
- ns-3 cannot be installed with `pip`. The simplest way is the image, for `linux/amd64`:
35
+ ns-3 cannot be installed with `pip`. The simplest way is the image, for `linux/amd64` and `linux/arm64`:
36
36
 
37
37
  ```bash
38
38
  docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3
@@ -50,7 +50,7 @@ The first run compiles `smol-ns3` against that build, which takes about 8 s, and
50
50
 
51
51
  The cross-backend suite ([ADR-0009](adr/0009-batch-execution-and-cross-backend-validation.md)) compares every backend with SimPy.
52
52
 
53
- **Rust** gives SimPy's results bit for bit: every sample, in every scenario.
53
+ **Rust** gives SimPy's results bit for bit on every deterministic scenario: every sample, down to the event count. Random traffic uses its own generator, so there the results agree statistically.
54
54
 
55
55
  **ns-3** runs SMOL's own full-duplex Ethernet device and switch, because ns-3's CSMA is half duplex. On top of them it runs ns-3's IP stack, and its random traffic is drawn from SimPy's streams. So:
56
56
  - **Ethernet** over UDP, with every pattern, IMIX and priorities, gives SimPy's results bit for bit. That holds for stochastic scenarios too, with the same seed.
@@ -172,7 +172,7 @@ A code-generated ns-3 scenario from the Scenario IR. Gives a realistic TCP/IP st
172
172
 
173
173
  ns-3 cannot be installed with `pip`, so the backend ships as a container image, `ghcr.io/jwszolek/smolpy:<version>-ns3`. It holds the pinned ns-3 release built once, and CI runs the ns-3 equivalence suite in it ([ADR-0004 — Container images](adr/0004-execution-backends.md#container-images)). A lighter image with SMOLPy and the Rust engine, without ns-3, can be published from the first release of `smolpy-engine-rs`.
174
174
 
175
- **Status: done.** All 3 steps are done, and so are the exit criteria. The ns-3 base image is built for `arm64` too, on a native runner; the `-ns3` image follows it there.
175
+ **Status: done.** All 3 steps are done, and so are the exit criteria. The ns-3 images are built for `arm64` too, on a native runner.
176
176
  1. **The image without ns-3: done.** `ghcr.io/jwszolek/smolpy:<version>` holds SMOLPy and the Rust engine, for `linux/amd64` and `linux/arm64`. It is built, tested and pushed at each release.
177
177
  2. **The ns-3 base image: done.** `ghcr.io/jwszolek/smolpy-ns3-base:3.49` holds ns-3.49, built once, for `linux/amd64` and `linux/arm64`, each on a runner of its own architecture.
178
178
  3. **The ns-3 backend.**
@@ -188,7 +188,7 @@ ns-3 cannot be installed with `pip`, so the backend ships as a container image,
188
188
  - **PROFINET: done.** PROFINET RT runs on layer 2, on SMOL's Ethernet device, with the three PROFINET metrics.
189
189
  - Every PROFINET scenario of the suite is bit-exact with SimPy, watchdog expiries included.
190
190
  - A frame that arrives exactly at the watchdog's deadline is too late on both engines.
191
- - **The image: done.** `ghcr.io/jwszolek/smolpy:<version>-ns3` and `latest-ns3`, for `linux/amd64`, hold the base image, SMOLPy and the Rust engine, and `smol-ns3` built in.
191
+ - **The image: done.** `ghcr.io/jwszolek/smolpy:<version>-ns3` and `latest-ns3`, for `linux/amd64` and `linux/arm64`, hold the base image, SMOLPy and the Rust engine, and `smol-ns3` built in.
192
192
  - Each release builds it from the release's wheels.
193
193
  - Before it is pushed, CI runs a `.smol` file on ns-3 through the CLI, and the ns-3 suite against the SMOLPy installed in it.
194
194
  - **Under load: done.** `python -m benchmarks load` compares Modbus and MQTT on ns-3's TCP with SimPy on a plant cell whose uplink loads up to 150 % ([Execution backends](backends.md#modbus-and-mqtt-over-tcp)).
@@ -72,7 +72,7 @@ link c -- sw: 'sw' has only 2 ports, all in use
72
72
 
73
73
  | Element | Rules |
74
74
  |---|---|
75
- | nodes | IPv4 address; MAC address of six hex bytes; `ports` ≥ 1; switch `mode`, `qos`, `mac_table`; Modbus `unit_id` 0–255 |
75
+ | nodes | IPv4 address; MAC address of six hex bytes; `ports` ≥ 1; switch `mode`, `qos`, `mac_table`, and `buffer_bytes`, a whole number of bytes of at least 1 522 and of the largest frame in the scenario; Modbus `unit_id` 0–255 |
76
76
  | links | not to itself; `speed` > 0; `length` ≥ 0 |
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) |
@@ -152,4 +152,4 @@ Each node and traffic entry carries a `kind`: `adapter`, `switch`, `mqtt_broker`
152
152
  - an unknown `kind` or field;
153
153
  - a missing required field.
154
154
 
155
- Optional fields that are left out take their defaults. Under ADR-0007, a new optional field does not change the version, and any change in meaning does.
155
+ Optional fields that are left out take their defaults. Under ADR-0007, a new optional field does not change the version, and any change in meaning does. A switch's `buffer_bytes` ([ADR-0011](adr/0011-bounded-switch-buffers.md)) is written only when it is set, so documents without bounded switches are as before.
@@ -53,6 +53,7 @@ nav:
53
53
  - ADR-0008 Rust DES Engine (MVP): adr/0008-rust-des-engine-mvp.md
54
54
  - ADR-0009 Batch Execution and Cross-Backend Validation: adr/0009-batch-execution-and-cross-backend-validation.md
55
55
  - ADR-0010 Ethernet Frames on the Wire: adr/0010-ethernet-frames-on-the-wire.md
56
+ - ADR-0011 Bounded Switch Buffers: adr/0011-bounded-switch-buffers.md
56
57
 
57
58
  markdown_extensions:
58
59
  - admonition
@@ -1,4 +1,5 @@
1
- //! Reads Scenario IR JSON, format "smol-ir" version 2 (ADR-0007, ADR-0010).
1
+ //! Reads Scenario IR JSON, format "smol-ir" version 2 (ADR-0007, ADR-0010),
2
+ //! with the optional switch buffers of ADR-0011.
2
3
  //!
3
4
  //! The scenario has already been validated by `smolpy.model.validate`; this
4
5
  //! reader is strict about structure (unknown fields, kinds and versions are
@@ -431,6 +432,10 @@ fn parse_node(value: Value, i: usize) -> Res<Node> {
431
432
  Some("topology") => true,
432
433
  Some(other) => return Err(format!("switch {name}: unknown mac_table {other:?}")),
433
434
  };
435
+ match f.take_or("buffer_bytes") {
436
+ None | Some(Value::Null) => {}
437
+ Some(_) => return Err(unsupported("bounded switch buffers")),
438
+ }
434
439
  NodeKind::Switch { fifo, topology }
435
440
  }
436
441
  "modbus_slave" => {
@@ -652,6 +657,11 @@ mod tests {
652
657
  assert!(parse(&B1.replace("\"version\": 2", "\"version\": 1"))
653
658
  .unwrap_err()
654
659
  .contains("version 1"));
660
+ assert!(
661
+ parse(&B1.replace("\"learning\"", "\"learning\", \"buffer_bytes\": 4000"))
662
+ .unwrap_err()
663
+ .contains("bounded switch buffers")
664
+ );
655
665
  assert!(
656
666
  parse(&B1.replace("\"priority\": 0", "\"priority\": 0, \"x\": 1"))
657
667
  .unwrap_err()