smolpy 1.9.1.dev8__tar.gz → 1.9.1.dev13__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 (147) hide show
  1. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/docker-image.yml +92 -8
  2. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/publish.yml +2 -2
  3. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/PKG-INFO +11 -2
  4. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/README.md +10 -1
  5. smolpy-1.9.1.dev13/docker/Dockerfile.ns3 +46 -0
  6. smolpy-1.9.1.dev13/docker/Dockerfile.ns3.dockerignore +3 -0
  7. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docker/smoke.smol +2 -1
  8. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0004-execution-backends.md +22 -3
  9. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +1 -1
  10. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/dsl-reference.md +1 -1
  11. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/roadmap.md +8 -2
  12. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/backends.py +12 -8
  13. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/ns3/__init__.py +32 -9
  14. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/ns3/cpp/smol-ns3.cc +197 -5
  15. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_ns3.py +68 -21
  16. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/ci.yml +0 -0
  17. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/dev-build.yml +0 -0
  18. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/docs.yml +0 -0
  19. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/github-release.yml +0 -0
  20. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/ns3-base.yml +0 -0
  21. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/release.yml +0 -0
  22. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.github/workflows/rust-wheels.yml +0 -0
  23. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/.gitignore +0 -0
  24. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/LICENSE +0 -0
  25. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/__init__.py +0 -0
  26. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/__main__.py +0 -0
  27. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
  28. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
  29. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
  30. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
  31. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
  32. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
  33. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
  34. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/runner.py +0 -0
  35. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/scenarios.py +0 -0
  36. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/benchmarks/worker.py +0 -0
  37. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docker/Dockerfile +0 -0
  38. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docker/Dockerfile.dockerignore +0 -0
  39. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docker/ns3-base/Dockerfile +0 -0
  40. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docker/ns3-base/smoke.cc +0 -0
  41. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0001-protocol-package-structure.md +0 -0
  42. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
  43. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0003-smol-external-dsl.md +0 -0
  44. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0005-profinet-rt.md +0 -0
  45. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
  46. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
  47. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
  48. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
  49. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/benchmarks.md +0 -0
  50. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/dashboard.md +0 -0
  51. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/examples.md +0 -0
  52. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/index.md +0 -0
  53. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/language-reference.md +0 -0
  54. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/modbus.md +0 -0
  55. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/model-semantics.md +0 -0
  56. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/mqtt.md +0 -0
  57. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/profinet.md +0 -0
  58. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/scenario-model.md +0 -0
  59. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/docs/simulation-engine.md +0 -0
  60. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/README.md +0 -0
  61. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example.py +0 -0
  62. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example.smol +0 -0
  63. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_10_clients.py +0 -0
  64. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_12_clients.py +0 -0
  65. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_20_clients.py +0 -0
  66. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_file_transfer.py +0 -0
  67. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_modbus.py +0 -0
  68. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_mqtt.py +0 -0
  69. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_profinet.py +0 -0
  70. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_profinet.smol +0 -0
  71. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_staggered_transfer.py +0 -0
  72. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/examples/example_two_tier.py +0 -0
  73. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/mkdocs.yml +0 -0
  74. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/pyproject.toml +0 -0
  75. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/Cargo.lock +0 -0
  76. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/Cargo.toml +0 -0
  77. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/Cargo.toml +0 -0
  78. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/src/frames.rs +0 -0
  79. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/src/lib.rs +0 -0
  80. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/src/rng.rs +0 -0
  81. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/src/scenario.rs +0 -0
  82. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/src/sim.rs +0 -0
  83. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smol-engine/src/timebase.rs +0 -0
  84. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smolpy-engine-rs/Cargo.toml +0 -0
  85. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smolpy-engine-rs/README.md +0 -0
  86. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smolpy-engine-rs/pyproject.toml +0 -0
  87. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smolpy-engine-rs/smoke_test.py +0 -0
  88. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/rust/smolpy-engine-rs/src/lib.rs +0 -0
  89. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/__init__.py +0 -0
  90. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/_worker.py +0 -0
  91. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/batch.py +0 -0
  92. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/cli.py +0 -0
  93. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/__init__.py +0 -0
  94. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/adapter.py +0 -0
  95. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/batch.py +0 -0
  96. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/link.py +0 -0
  97. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/network.py +0 -0
  98. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/node.py +0 -0
  99. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/core/observation.py +0 -0
  100. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/ethernet/__init__.py +0 -0
  101. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/ethernet/switch.py +0 -0
  102. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/lang/__init__.py +0 -0
  103. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/lang/ast.py +0 -0
  104. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/lang/errors.py +0 -0
  105. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/lang/grammar.lark +0 -0
  106. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/lang/interpreter.py +0 -0
  107. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/lang/transformer.py +0 -0
  108. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/modbus/__init__.py +0 -0
  109. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/modbus/slave.py +0 -0
  110. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/model/__init__.py +0 -0
  111. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/model/frames.py +0 -0
  112. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/model/scenario.py +0 -0
  113. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/model/streams.py +0 -0
  114. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/model/timebase.py +0 -0
  115. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/model/validate.py +0 -0
  116. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/mqtt/__init__.py +0 -0
  117. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/mqtt/broker.py +0 -0
  118. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/profinet/__init__.py +0 -0
  119. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/profinet/device.py +0 -0
  120. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/sim/__init__.py +0 -0
  121. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/sim/engine.py +0 -0
  122. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/stats.py +0 -0
  123. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/viz/__init__.py +0 -0
  124. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/viz/dashboard.py +0 -0
  125. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/src/smolpy/viz/text_dashboard.py +0 -0
  126. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/__init__.py +0 -0
  127. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/equivalence/__init__.py +0 -0
  128. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/equivalence/harness.py +0 -0
  129. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/equivalence/scenarios.py +0 -0
  130. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/equivalence/test_equivalence.py +0 -0
  131. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/equivalence/test_rust_timebase.py +0 -0
  132. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_backends.py +0 -0
  133. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_batch.py +0 -0
  134. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_benchmarks.py +0 -0
  135. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_cli.py +0 -0
  136. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_dsl.py +0 -0
  137. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_engine_ir.py +0 -0
  138. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_lang.py +0 -0
  139. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_model.py +0 -0
  140. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_profinet.py +0 -0
  141. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_semantics.py +0 -0
  142. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_simulation.py +0 -0
  143. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_stats.py +0 -0
  144. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_sweep.py +0 -0
  145. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_timebase.py +0 -0
  146. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/tests/test_validate.py +0 -0
  147. {smolpy-1.9.1.dev8 → smolpy-1.9.1.dev13}/uv.lock +0 -0
@@ -1,15 +1,18 @@
1
1
  name: Docker image
2
2
 
3
- # The image without ns-3, ghcr.io/jwszolek/smolpy (ADR-0004, Container
4
- # images): Python, smolpy and smolpy-engine-rs for linux/amd64 and
5
- # linux/arm64, installed from the wheels of one version. Every image is tested
6
- # before anything is pushed: the wheel smoke test (bit-exact with SimPy) and a
7
- # .smol run through the CLI.
3
+ # The images of ghcr.io/jwszolek/smolpy (ADR-0004, Container images), from
4
+ # the wheels of one version of smolpy and smolpy-engine-rs:
5
+ # - <version>, latest: without ns-3, for linux/amd64 and linux/arm64;
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).
8
+ # Every image is tested before anything is pushed: a .smol run through the
9
+ # CLI; the wheel smoke test (bit-exact with SimPy) without ns-3, and the ns-3
10
+ # suite with it.
8
11
  #
9
12
  # - Called by publish.yml at a release, once both packages are on PyPI: uses
10
- # the files of the same run and pushes <version> and latest.
11
- # - On a pull request that touches the image: builds the wheels here, for
12
- # linux/amd64 only, tests that image and pushes nothing.
13
+ # 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.
13
16
 
14
17
  on:
15
18
  pull_request:
@@ -40,6 +43,9 @@ jobs:
40
43
  IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy
41
44
  RELEASE: ${{ inputs.version && 'true' || 'false' }} # no inputs on a pull request
42
45
 
46
+ outputs:
47
+ version: ${{ steps.v.outputs.version }}
48
+
43
49
  steps:
44
50
  - uses: actions/checkout@v4
45
51
  with:
@@ -104,6 +110,14 @@ jobs:
104
110
  echo "version=$VERSION" >> "$GITHUB_OUTPUT"
105
111
  ls dist/
106
112
 
113
+ # the same wheels, for the ns-3 image
114
+ - name: Keep the wheels
115
+ uses: actions/upload-artifact@v4
116
+ with:
117
+ name: image-wheels
118
+ path: dist/*.whl
119
+ retention-days: 1
120
+
107
121
  - name: Set up QEMU, for linux/arm64
108
122
  if: ${{ env.RELEASE == 'true' }}
109
123
  uses: docker/setup-qemu-action@v3
@@ -151,3 +165,73 @@ jobs:
151
165
  --build-arg VERSION="$VERSION" -f docker/Dockerfile \
152
166
  -t "$IMAGE:$VERSION" -t "$IMAGE:latest" .
153
167
  echo "Pushed $IMAGE:$VERSION and $IMAGE:latest" >> "$GITHUB_STEP_SUMMARY"
168
+
169
+ image-ns3:
170
+ name: ${{ inputs.version && format('Image {0}-ns3', inputs.version) || 'Image with ns-3 (test build)' }}
171
+ needs: image
172
+ runs-on: ubuntu-latest
173
+ permissions:
174
+ contents: read
175
+ packages: write # push to ghcr.io
176
+
177
+ env:
178
+ IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy
179
+ RELEASE: ${{ inputs.version && 'true' || 'false' }}
180
+ VERSION: ${{ needs.image.outputs.version }}
181
+
182
+ steps:
183
+ - uses: actions/checkout@v4
184
+ with:
185
+ ref: ${{ inputs.ref }}
186
+
187
+ - name: Download the wheels
188
+ uses: actions/download-artifact@v4
189
+ with:
190
+ name: image-wheels
191
+ path: dist/
192
+
193
+ - uses: docker/setup-buildx-action@v3
194
+
195
+ # smol-ns3 is built into the image; its cache is read-only, so a run
196
+ # below that needed another build would fail
197
+ - name: Build
198
+ run: |
199
+ docker buildx build --platform linux/amd64 --load \
200
+ --build-arg VERSION="$VERSION" -f docker/Dockerfile.ns3 -t smolpy:test-ns3 .
201
+ docker image ls smolpy:test-ns3
202
+
203
+ - name: Test the CLI on ns-3
204
+ run: |
205
+ docker run --rm smolpy:test-ns3 --help
206
+ mkdir -p out && chmod 777 out
207
+ cp docker/smoke.smol out/
208
+ docker run --rm -v "$PWD/out:/work" \
209
+ smolpy:test-ns3 run smoke.smol --backend ns3 -o results.csv
210
+ grep -q "pn_latency:plc" out/results.csv
211
+ grep -q "modbus_latency:plc" out/results.csv
212
+ rm -rf out
213
+
214
+ # the tests of this version, against the smolpy installed in the image
215
+ - name: Run the ns-3 suite in the image
216
+ run: |
217
+ docker run --rm --user 0 -e PYTHONDONTWRITEBYTECODE=1 \
218
+ -v "$PWD/tests:/src/tests:ro" -w /src --entrypoint sh smolpy:test-ns3 -c \
219
+ "pip install --quiet --root-user-action=ignore pytest \
220
+ && python -m pytest -p no:cacheprovider tests/equivalence tests/test_ns3.py -k ns3 -q"
221
+
222
+ - name: Log in to ghcr.io
223
+ if: ${{ env.RELEASE == 'true' }}
224
+ uses: docker/login-action@v3
225
+ with:
226
+ registry: ghcr.io
227
+ username: ${{ github.actor }}
228
+ password: ${{ secrets.GITHUB_TOKEN }}
229
+
230
+ - name: Push
231
+ if: ${{ env.RELEASE == 'true' }}
232
+ 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"
@@ -4,8 +4,8 @@ name: Publish to PyPI
4
4
  #
5
5
  # - Release (a pushed tag v*, or release.yml passing its tag): publishes
6
6
  # smolpy and the smolpy-engine-rs wheels and sdist to PyPI with the tag's
7
- # version, then the GitHub Release with every file and the Docker image
8
- # ghcr.io/jwszolek/smolpy:<version> (docker-image.yml).
7
+ # version, then the GitHub Release with every file and the Docker images
8
+ # ghcr.io/jwszolek/smolpy:<version> and <version>-ns3 (docker-image.yml).
9
9
  # - Development build (dev-build.yml, dev: true, after a merge to main):
10
10
  # publishes both to PyPI as X.Y.(Z+1).devN, N commits after the latest tag,
11
11
  # a pre-release that pip installs only with --pre, and replaces the GitHub
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: smolpy
3
- Version: 1.9.1.dev8
3
+ Version: 1.9.1.dev13
4
4
  Summary: Network simulation DSL and discrete-event simulator
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -99,6 +99,15 @@ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend
99
99
  - It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
100
100
  - A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
101
101
 
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
+
104
+ ```bash
105
+ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
106
+ ```
107
+
108
+ - It is about 1.3 GB (300 MB to download), because it holds ns-3's build and a C++ toolchain.
109
+ - It contains ns-3, so it is distributed under GPLv2's terms. SMOLPy itself stays MIT.
110
+
102
111
  From a clone, for development:
103
112
 
104
113
  ```bash
@@ -482,7 +491,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
482
491
  |---|---|---|---|---|
483
492
  | `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
484
493
  | `rust` | Rust, through PyO3 | the whole model, headless: Ethernet, Modbus TCP, MQTT and PROFINET RT, every metric | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
485
- | `ns3` (in progress) | ns-3's IPv4 stack, from C++ | Ethernet over UDP, bit-exact with SimPy: adapters, switches, every traffic pattern, IMIX, priorities. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements. PROFINET not yet | slower: each run is an ns-3 process | an ns-3 3.49 build in `NS3_HOME`, e.g. the image `ghcr.io/jwszolek/smolpy-ns3-base:3.49` |
494
+ | `ns3` | ns-3's IPv4 stack, from C++ | the whole model, headless. Ethernet over UDP and PROFINET RT on layer 2, bit-exact with SimPy. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements | slower: each run is an ns-3 process | the image `ghcr.io/jwszolek/smolpy:latest-ns3`, or an ns-3 3.49 build in `NS3_HOME` |
486
495
 
487
496
  ```python
488
497
  result = net.simulate(duration=60_000, backend="rust") # one run
@@ -71,6 +71,15 @@ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy run plant.smol --backend
71
71
  - It runs as uid 1000. To own the files it writes as yourself, add `--user "$(id -u):$(id -g)"`.
72
72
  - A version is pinned as `ghcr.io/jwszolek/smolpy:<version>`; `latest` is the latest release.
73
73
 
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
+
76
+ ```bash
77
+ docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3 -o results.csv
78
+ ```
79
+
80
+ - It is about 1.3 GB (300 MB to download), because it holds ns-3's build and a C++ toolchain.
81
+ - It contains ns-3, so it is distributed under GPLv2's terms. SMOLPy itself stays MIT.
82
+
74
83
  From a clone, for development:
75
84
 
76
85
  ```bash
@@ -454,7 +463,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
454
463
  |---|---|---|---|---|
455
464
  | `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
456
465
  | `rust` | Rust, through PyO3 | the whole model, headless: Ethernet, Modbus TCP, MQTT and PROFINET RT, every metric | about **40× faster**: B1 at 10 M frames in 4.9 s, not 200.8 s | `pip install smolpy[rust]` (since v1.8.0) |
457
- | `ns3` (in progress) | ns-3's IPv4 stack, from C++ | Ethernet over UDP, bit-exact with SimPy: adapters, switches, every traffic pattern, IMIX, priorities. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements. PROFINET not yet | slower: each run is an ns-3 process | an ns-3 3.49 build in `NS3_HOME`, e.g. the image `ghcr.io/jwszolek/smolpy-ns3-base:3.49` |
466
+ | `ns3` | ns-3's IPv4 stack, from C++ | the whole model, headless. Ethernet over UDP and PROFINET RT on layer 2, bit-exact with SimPy. Modbus TCP and MQTT over ns-3's TCP, which adds connection setup and acknowledgements | slower: each run is an ns-3 process | the image `ghcr.io/jwszolek/smolpy:latest-ns3`, or an ns-3 3.49 build in `NS3_HOME` |
458
467
 
459
468
  ```python
460
469
  result = net.simulate(duration=60_000, backend="rust") # one run
@@ -0,0 +1,46 @@
1
+ # SMOLPy with ns-3: ghcr.io/jwszolek/smolpy:<version>-ns3 (ADR-0004,
2
+ # Container images). Built by .github/workflows/docker-image.yml.
3
+ #
4
+ # The ns-3 base image, with the pinned ns-3 build and its toolchain, plus
5
+ # smolpy and smolpy-engine-rs from the wheels of one version, as in the image
6
+ # without ns-3. smol-ns3, the program that runs scenarios on ns-3, is built
7
+ # here once, so that no run compiles it.
8
+ #
9
+ # docker run --rm -v "$PWD:/work" ghcr.io/jwszolek/smolpy:latest-ns3 run plant.smol --backend ns3
10
+ #
11
+ # The image contains ns-3, licensed under GPLv2, and smol-ns3 linked against
12
+ # it, so the image as a whole is distributed under GPLv2's terms. SMOLPy's own
13
+ # code is MIT. The sources: ns-3 at the commit the base image records, and
14
+ # smol-ns3 in smolpy/ns3/cpp.
15
+
16
+ ARG NS3_BASE=ghcr.io/jwszolek/smolpy-ns3-base:3.49
17
+ FROM ${NS3_BASE}
18
+
19
+ ARG VERSION
20
+
21
+ LABEL org.opencontainers.image.title="SMOLPy with ns-3" \
22
+ org.opencontainers.image.description="Network simulation DSL and discrete-event simulator, with the Rust engine and the ns-3 backend" \
23
+ org.opencontainers.image.source="https://github.com/jwszolek/SMOLPy" \
24
+ org.opencontainers.image.documentation="https://jwszolek.github.io/SMOLPy/" \
25
+ org.opencontainers.image.licenses="GPL-2.0-only AND MIT" \
26
+ org.opencontainers.image.version="${VERSION}"
27
+
28
+ RUN --mount=type=bind,source=dist,target=/dist \
29
+ test -n "${VERSION}" \
30
+ && pip install --no-cache-dir --find-links /dist \
31
+ "smolpy[rust]==${VERSION}" "smolpy-engine-rs==${VERSION}" \
32
+ && python -c "import smolpy_engine_rs; assert smolpy_engine_rs.__version__ == '${VERSION}'"
33
+
34
+ # smol-ns3, built for this ns-3 build into a cache every user reads. It is
35
+ # not writable: a run that would need another build (another CXX) fails,
36
+ # saying to set XDG_CACHE_HOME to a writable directory to build it there.
37
+ ENV XDG_CACHE_HOME=/opt/smolpy/cache
38
+ RUN python -c "from smolpy import ns3; print(ns3.program(ns3.locate()))" \
39
+ && chmod -R a+rX,go-w /opt/smolpy
40
+
41
+ RUN useradd --create-home --uid 1000 smolpy
42
+ USER 1000
43
+ WORKDIR /work
44
+
45
+ ENTRYPOINT ["smolpy"]
46
+ CMD ["--help"]
@@ -0,0 +1,3 @@
1
+ # The image is built from the repository root, but needs only the wheels.
2
+ *
3
+ !dist/
@@ -1,5 +1,6 @@
1
1
  # Run by CI in every image it builds: the CLI, a .smol file and the Rust
2
- # engine, with every protocol, writing its results to the mounted directory.
2
+ # engine, or ns-3 in the -ns3 image, with every protocol, writing its results
3
+ # to the mounted directory.
3
4
 
4
5
  network "image-smoke" {
5
6
 
@@ -117,6 +117,7 @@ smolpy backends # list backends and their capabiliti
117
117
  | SMOL | ns-3 |
118
118
  |---|---|
119
119
  | `adapter`, `mqtt_broker`, `modbus_slave` | Node with Internet stack (IPv4 address from `ip`) |
120
+ | `profinet_device`, `controls` | *Added 2026-11-16:* a node whose device sends and receives PROFINET RT frames on layer 2; see "PROFINET RT on ns-3" below |
120
121
  | `switch` (store-and-forward) | ~~Node with a learning bridge over one device per port~~ *As built:* a node with one SMOL Ethernet device per port and SMOL's switch, which learns, floods unknown destinations and drops hairpins. ns-3's `BridgeNetDevice` floods a hairpin instead of dropping it. |
121
122
  | `switch mode=cut-through` | **unsupported** — capability error |
122
123
  | `hub` | Shared CSMA channel *(hubs and `collision_rate` were later removed; see [Model Semantics](../model-semantics.md#open-issues), open issue 3)* |
@@ -151,7 +152,7 @@ smolpy backends # list backends and their capabiliti
151
152
  | `bytes_sent` | frames whose transmission on the node's device has completed (`PhyTxEnd`), frame bytes |
152
153
  | `latency` | from the origin time, carried in a packet tag set when the data is created, to reception by the device. Queueing at the sender is included, as in SimPy. |
153
154
  | `modbus_latency` | the same, with the request's origin tag copied into the response. *As built:* measured when the master has the whole response. |
154
- | `pn_latency`, `pn_jitter`, `pn_watchdog_expiries` | the SMOL PROFINET consumer application, with the definitions of Model Semantics §7 |
155
+ | `pn_latency`, `pn_jitter`, `pn_watchdog_expiries` | the SMOL PROFINET consumer application, with the definitions of Model Semantics §7. *As built:* the node's consumer, called by its device for each PROFINET frame; see "PROFINET RT on ns-3" below. |
155
156
  | `queue_depth` | frames waiting in the egress queues of the switch's devices, not counting the frame in transmission |
156
157
  | `utilization` | frame + 20 B per frame completed on the links into the node, as a share of their capacity (ADR-0010) |
157
158
  | `broker_queue` | the queue of the broker application. *As built:* messages waiting for a subscriber's connection, which the subscriber has not yet opened. The broker handles a message at once, as on SimPy, so the queue is otherwise empty. |
@@ -182,12 +183,19 @@ ns-3 is the one backend that cannot be installed with `pip`. It is a C++ code ba
182
183
 
183
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.
184
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`:
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
+ - **`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
+ - **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.
190
+ - **Tags.** `<version>-ns3` and `latest-ns3`, first published with 1.10.0. `latest` remains the image without ns-3.
191
+ - **Size.** 1.26 GB unpacked, 303 MB compressed, for 1.9.1.dev9. ns-3's build and the C++ toolchain stay in the image.
192
+
185
193
  **Registry and images.** The images are published to the GitHub Container Registry, `ghcr.io/jwszolek/smolpy`, public, for `linux/amd64` and `linux/arm64`:
186
194
 
187
195
  | Tag | Contents | Size | From |
188
196
  |---|---|---|---|
189
197
  | `<version>`, `latest` | Python, `smolpy` and `smolpy-engine-rs` from the release's own wheels | ~ 200 MB | the first release that publishes the Rust engine (ADR-0008 step 7) |
190
- | `<version>-ns3`, `latest-ns3` | the above, plus the pinned ns-3 release built with the SMOL C++ module, and `NS3_HOME` set | several GB | Phase 6, with the ns-3 backend |
198
+ | `<version>-ns3`, `latest-ns3` | the above, plus the pinned ns-3 release built with the SMOL C++ module, and `NS3_HOME` set | ~~several GB~~ *as built:* 1.3 GB, 300 MB compressed | Phase 6, with the ns-3 backend |
191
199
 
192
200
  The entry point is the CLI:
193
201
 
@@ -199,7 +207,7 @@ docker run --rm -v "$PWD:/work" -w /work ghcr.io/jwszolek/smolpy:latest-ns3 run
199
207
  - **Headless only.** The live dashboard needs a display, which a container does not have. Headless runs, text mode, `--runs` and `-o` all work.
200
208
  - **Built at release.** `publish.yml` builds and pushes the images at each release, after `smolpy` and `smolpy-engine-rs` are on PyPI, from the same files. The pushed images are listed under the repository's "Packages". The Dockerfiles live in `docker/`.
201
209
  - **ns-3 is built once per pinned release.** It is built in a separate base image, `ghcr.io/jwszolek/smolpy-ns3-base:<ns-3 version>`, which is rebuilt only when the pinned version changes. Each release then adds SMOLPy to it in a few minutes, instead of rebuilding ns-3.
202
- - **CI uses the image.** The ns-3 equivalence suite (ADR-0009) runs inside `<version>-ns3`, or inside the base image for pull requests. It never builds ns-3 itself.
210
+ - **CI uses the image.** The ns-3 equivalence suite (ADR-0009) runs inside `<version>-ns3`, or inside the base image for pull requests. It never builds ns-3 itself. *As built (2026-11-16):* pull requests run it in the base image, against the SMOLPy of the pull request. Each release runs it in the new `<version>-ns3` image before pushing it.
203
211
  - **Reproducible results.** An image tag fixes the SMOLPy, Rust engine and ns-3 versions together. Recording the image digest next to the scenario JSON, and the generated ns-3 scenario (`--keep-generated`), is enough to rerun a published experiment exactly.
204
212
  - **Licences.** ns-3 is licensed under GPLv2, and SMOLPy and its Rust engine under MIT.
205
213
  - The `-ns3` image distributes ns-3 binaries and the SMOL C++ module linked against them, so that image as a whole is distributed under GPLv2's terms.
@@ -279,6 +287,17 @@ What ns-3 is there for is its TCP. The backend therefore keeps everything else a
279
287
  - **Low load.** After the first messages, ns-3 is SimPy plus 2 ns per message. The remaining differences are the handshake, the first acknowledgement, and the acknowledgements of one-way traffic.
280
288
  - **Loaded.** The acknowledgements reorder frames in shared queues, so differences remain throughout the run. They are reported, not asserted (ADR-0009). Quantifying them under heavier load, where TCP's flow and congestion control act, is the next part of this research.
281
289
 
290
+ **PROFINET RT on ns-3** *(built 2026-11-16)*
291
+
292
+ PROFINET RT is a layer 2 protocol (EtherType 0x8892), without IP, so ns-3's stack has nothing to add to it. The backend runs it on SMOL's Ethernet device, so that scenarios that mix PROFINET with flows, Modbus and MQTT run whole on ns-3.
293
+ - **Providers.** Each AR has a provider on the controller (outputs) and on the device (inputs). Each one hands a frame to its device every cycle, from the AR's start delay on.
294
+ - Frames are sized by the model's formula (`pn_frame_size`), 802.1Q tag and padding included.
295
+ - Their priority is 6, served strictly by the egress queues, or FIFO on a switch with `qos="fifo"`.
296
+ - The providers start by controller in node order, as on the reference engine.
297
+ - **Consumers.** Each node's consumer measures latency and jitter, and supervises each AR with a watchdog, as defined in Model Semantics §7. The watchdog is one ns-3 event at `hold × cycle` after the last frame. Each frame cancels it and sets it again.
298
+ - **The deadline comes first.** A frame that arrives exactly at the deadline was scheduled after the watchdog, at the end of its transmission. ns-3 runs events of one instant in the order they were scheduled, so the expiry counts, and the frame then restarts supervision. That is SimPy's outcome, where the watchdog's timeout fires before the frame is delivered.
299
+ - **Results.** `priorities`, `cyclic` and `batches` (with the same seed) give SimPy's results bit for bit. That includes watchdog expiries under load, and a hold of one cycle with no jitter, where every frame arrives at its deadline (`test_a_frame_at_the_watchdogs_deadline_is_too_late`).
300
+
282
301
  **The ns-3 base image, as built** *(2026-11-16)*:
283
302
  - `ghcr.io/jwszolek/smolpy-ns3-base:3.49`, built by `.github/workflows/ns3-base.yml` from `docker/ns3-base/Dockerfile`, for `linux/amd64` only for now. It is rebuilt when that Dockerfile changes, and pushed after the merge to `main`.
284
303
  - **Pinned release:** ns-3.49 (released 2026-10-07), as the git tag `ns-3.49` with its commit checked. Debian 12's g++ 12 and CMake 3.25 meet its minimums: g++ 11.1, C++23 and CMake 3.25.
@@ -87,7 +87,7 @@ The suite lives in `tests/equivalence/`. It runs a fixed set of reference scenar
87
87
  |---|---|
88
88
  | **Deterministic** (constant patterns, fixed sizes, no randomness) | ~~Per metric window: \|a − b\| ≤ abs_tol + rel_tol·\|b\|. The tolerance only covers time representation (SimPy float µs vs Rust integer ns); default `rel_tol = 1e-6`, `abs_tol` = 1 ns-equivalent in the metric's unit.~~ *Amended by the ADR-0007 revision of 2026-11-14 ([integer nanoseconds](0007-execution-independent-scenario-model.md#simulated-time-integer-nanoseconds)):* every metric window must match exactly, sample times and values bit for bit (in place since ADR-0007 step 8). |
89
89
  | **Stochastic** | 30 replications per backend. For each metric's per-run scalar, the ~~95 %~~ confidence interval of the difference of means must contain 0, and the relative difference of means must be under 2 %. *Amended 2026-11-15:* with *k* metrics in a scenario, each interval is at the Bonferroni level `1 − 0.05/k`, e.g. 98.75 % for 4 metrics. Two equivalent backends then fail a scenario by chance at most 5 % of the time. With 95 % per metric they failed about one seed block in ten, and now one in forty (measured over 20 blocks per scenario). |
90
- | **High-fidelity backends** (ns-3) | Low-load scenarios: same rules as stochastic. Loaded scenarios: differences are **reported, not asserted** (ADR-0004). Quantifying them is a research result. *Amended 2026-11-16:* on SMOL's own Ethernet with UDP, ns-3 gives SimPy's results bit for bit, so the deterministic scenarios in its scope are compared exactly, as for Rust. ns-3 draws random traffic from the reference engine's streams, so a stochastic scenario with the same seed must also match bit for bit (`test_same_streams_give_the_same_run`), besides the statistical comparison. These rules remain for TCP, where ns-3's stack is meant to differ. *Amended 2026-11-16:* ns-3 runs Modbus and MQTT over TCP. For a scenario with that traffic, the suite checks that ns-3 samples the same metrics at the same instants, and reports the differences in their means (`test_over_tcp`). Tests of small scenarios check what TCP adds to the nanosecond (ADR-0004). |
90
+ | **High-fidelity backends** (ns-3) | Low-load scenarios: same rules as stochastic. Loaded scenarios: differences are **reported, not asserted** (ADR-0004). Quantifying them is a research result. *Amended 2026-11-16:* on SMOL's own Ethernet with UDP, ns-3 gives SimPy's results bit for bit, so the deterministic scenarios in its scope are compared exactly, as for Rust. ns-3 draws random traffic from the reference engine's streams, so a stochastic scenario with the same seed must also match bit for bit (`test_same_streams_give_the_same_run`), besides the statistical comparison. These rules remain for TCP, where ns-3's stack is meant to differ. *Amended 2026-11-16:* ns-3 runs Modbus and MQTT over TCP. For a scenario with that traffic, the suite checks that ns-3 samples the same metrics at the same instants, and reports the differences in their means (`test_over_tcp`). Tests of small scenarios check what TCP adds to the nanosecond (ADR-0004). PROFINET RT on ns-3 is layer 2 and is compared exactly, like Ethernet. |
91
91
 
92
92
  - Backends that are not installed are skipped.
93
93
  - **CI:** SimPy against itself (a sanity check of the harness) and Rust against SimPy when the Rust package is available.
@@ -165,7 +165,7 @@ result.export("out.csv", format="csv") # explicit format override
165
165
  |---|---|
166
166
  | `"simpy"` | The reference implementation. It is the default, always installed, and runs the whole model, including the live and text dashboards. |
167
167
  | `"rust"` | The native engine of [ADR-0008](adr/0008-rust-des-engine-mvp.md), from the optional package `smolpy-engine-rs` (`pip install smolpy[rust]`). It runs headless. |
168
- | `"ns3"` | ns-3 ([ADR-0004](adr/0004-execution-backends.md)), in progress: so far Ethernet (adapters, switches, flows with every pattern, IMIX and 802.1Q priorities, the Ethernet metrics) on ns-3's IPv4/UDP stack, with random traffic drawn from SimPy's streams; and Modbus TCP and MQTT on ns-3's TCP, with `modbus_latency` and `broker_queue`. TCP's connection setup and acknowledgements make those results differ from SimPy's. PROFINET is not supported yet. It needs `NS3_HOME`, naming a built ns-3 3.49 tree, and a C++ compiler; the image `ghcr.io/jwszolek/smolpy-ns3-base:3.49` has both. It runs headless. |
168
+ | `"ns3"` | ns-3 ([ADR-0004](adr/0004-execution-backends.md)), the whole model. Ethernet (flows with every pattern, IMIX and 802.1Q priorities) runs on ns-3's IPv4/UDP stack, with random traffic drawn from SimPy's streams. PROFINET RT runs on layer 2. Both give SimPy's results bit for bit. Modbus TCP and MQTT run on ns-3's TCP, whose connection setup and acknowledgements make those results differ from SimPy's. It runs in the image `ghcr.io/jwszolek/smolpy:<version>-ns3`. Elsewhere it needs `NS3_HOME`, naming a built ns-3 3.49 tree, and a C++ compiler. It runs headless. |
169
169
 
170
170
  - **What a backend can run is checked before the run.** Every backend declares what it supports: node kinds, traffic kinds, patterns and metrics. A scenario that uses anything else is rejected with a `ScenarioError` naming the element. A dashboard (`live=True` or `text=True`) on a headless backend is a `ValueError`.
171
171
  - **A missing backend is an error.** When a backend is not installed, selecting it raises `BackendUnavailable` with the install command.
@@ -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:** steps 1 and 2 of 3 done, and step 3 is under way.
175
+ **Status:** all 3 steps done. What remains for the exit criteria is quantifying the differences under load.
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`. `arm64` follows on a native runner.
178
178
  3. **The ns-3 backend.**
@@ -185,7 +185,13 @@ ns-3 cannot be installed with `pip`, so the backend ships as a container image,
185
185
  - Their frames have SMOL's sizes. What TCP adds is the handshake, acknowledgements and, under load, its flow and congestion control.
186
186
  - At low load, after the first messages, every Modbus round trip and MQTT delivery is SimPy's plus 2 ns. Tests check this to the nanosecond.
187
187
  - The suite checks that the TCP scenarios sample the same metrics at the same instants as SimPy, and reports how their values differ.
188
- - **Next:** PROFINET.
188
+ - **PROFINET: done.** PROFINET RT runs on layer 2, on SMOL's Ethernet device, with the three PROFINET metrics.
189
+ - Every PROFINET scenario of the suite is bit-exact with SimPy, watchdog expiries included.
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.
192
+ - Each release builds it from the release's wheels.
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
+ - **Next:** quantifying the differences under load, and `docs/backends.md`.
189
195
 
190
196
  **Exit criteria:**
191
197
 
@@ -160,9 +160,9 @@ class RustBackend:
160
160
  class Ns3Backend:
161
161
  """ns-3 (ADR-0004, ``smolpy.ns3``), where ``NS3_HOME`` names an ns-3 build.
162
162
 
163
- So far it runs Ethernet (adapters, switches and flows with every pattern,
164
- IMIX and 802.1Q priorities) over UDP, and Modbus TCP and MQTT over ns-3's
165
- TCP. PROFINET follows in Phase 6.
163
+ It runs the whole model, headless: Ethernet (adapters, switches and flows
164
+ with every pattern, IMIX and 802.1Q priorities) over UDP, Modbus TCP and
165
+ MQTT over ns-3's TCP, and PROFINET RT on layer 2.
166
166
  """
167
167
 
168
168
  name = "ns3"
@@ -190,10 +190,9 @@ class Ns3Backend:
190
190
 
191
191
  def capabilities(self) -> Capabilities:
192
192
  self._locate()
193
- later = "planned for Phase 6"
194
193
  return Capabilities(
195
- nodes=frozenset({"adapter", "switch", "mqtt_broker", "modbus_slave"}),
196
- traffic=frozenset({"flow", "publish", "route", "poll"}),
194
+ nodes=_NODE_KINDS,
195
+ traffic=_TRAFFIC_KINDS,
197
196
  patterns=_PATTERNS,
198
197
  metrics=frozenset(
199
198
  {
@@ -205,16 +204,21 @@ class Ns3Backend:
205
204
  "utilization",
206
205
  "modbus_latency",
207
206
  "broker_queue",
207
+ "pn_latency",
208
+ "pn_jitter",
209
+ "pn_watchdog_expiries",
208
210
  }
209
211
  ),
210
212
  features=frozenset({"imix"}),
211
- notes={kind: later for kind in ("profinet_device", "profinet_ar")},
212
213
  )
213
214
 
214
215
  def run(self, scenario: Scenario) -> SimulationResult:
215
216
  from smolpy import ns3
216
217
 
217
- return ns3.run(scenario)
218
+ try:
219
+ return ns3.run(scenario)
220
+ except ns3.Ns3Unavailable as exc: # e.g. smol-ns3 cannot be built
221
+ raise BackendUnavailable(f"the ns3 backend is not available: {exc}") from exc
218
222
 
219
223
 
220
224
  REGISTRY: dict[str, Backend] = {b.name: b for b in (SimPyBackend(), RustBackend(), Ns3Backend())}
@@ -1,5 +1,5 @@
1
1
  """The ns-3 backend (ADR-0004): SMOLPy scenarios on ns-3's IPv4 stack, with
2
- UDP for flows and TCP for Modbus and MQTT.
2
+ UDP for flows and TCP for Modbus and MQTT, and PROFINET RT on layer 2.
3
3
 
4
4
  A scenario is lowered to plain lines of integers (every time in integer
5
5
  nanoseconds, every speed and period an exact rational) and run by
@@ -40,6 +40,7 @@ from smolpy.model.frames import (
40
40
  MODBUS_REQUEST_MESSAGE_BYTES,
41
41
  modbus_response_message_bytes,
42
42
  mqtt_publish_message_bytes,
43
+ pn_frame_size,
43
44
  )
44
45
  from smolpy.model.streams import source_ids, stream_seed
45
46
 
@@ -111,7 +112,14 @@ def program(ns3: Installation) -> Path:
111
112
  target = _cache_dir() / key.hexdigest()[:16] / PROGRAM
112
113
  if target.is_file():
113
114
  return target
114
- target.parent.mkdir(parents=True, exist_ok=True)
115
+ try:
116
+ target.parent.mkdir(parents=True, exist_ok=True)
117
+ except OSError as exc: # e.g. the read-only cache of the -ns3 image
118
+ raise Ns3Unavailable(
119
+ f"{PROGRAM} for this ns-3 build and compiler ({ns3.compiler}) is not built, and"
120
+ f" cannot be built in {target.parent.parent}: {exc.strerror}. Set XDG_CACHE_HOME"
121
+ " to a writable directory to build it there."
122
+ ) from exc
115
123
  with tempfile.TemporaryDirectory(dir=target.parent) as tmp:
116
124
  src = Path(tmp) / "smol-ns3.cc"
117
125
  src.write_bytes(_source())
@@ -215,12 +223,10 @@ def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
215
223
  index = {n.name: i for i, n in enumerate(scenario.nodes)}
216
224
  lines = [f"smol-ns3 {FORMAT_VERSION}", f"duration {tb.ms_to_ns(scenario.run.duration_ms)}"]
217
225
  for n in scenario.nodes:
218
- if isinstance(n, model.AdapterNode | model.MqttBrokerNode | model.ModbusSlaveNode):
219
- lines.append(f"adapter {n.mac} {n.ip}") # an IPv4 host
220
- elif isinstance(n, model.SwitchNode):
226
+ if isinstance(n, model.SwitchNode):
221
227
  lines.append("switch")
222
- else: # the capabilities exclude it
223
- raise ValueError(f"the ns3 backend does not support {n.kind} nodes")
228
+ else:
229
+ lines.append(f"adapter {n.mac} {n.ip}") # a station, with IPv4
224
230
 
225
231
  next_port: dict[str, int] = {n.name: 0 for n in scenario.nodes}
226
232
  neighbours: dict[str, list[tuple[int, str]]] = {n.name: [] for n in scenario.nodes}
@@ -271,7 +277,19 @@ def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
271
277
  num, den = _ratio(tb.interval_ns(rate))
272
278
  return f"{tb.ms_to_ns(delay_ms)} {num} {den}"
273
279
 
280
+ # PROFINET ARs first, by controller in node order, as the reference engine
281
+ # starts them: their first frames are sent at the start of the run
282
+ ars = [t for t in scenario.traffic if isinstance(t, model.ProfinetAR)]
283
+ for ar_id, pn in enumerate(sorted(ars, key=lambda ar: index[ar.controller])):
284
+ if pn.controller in has_link and pn.device in has_link:
285
+ lines.append(
286
+ f"ar {index[pn.controller]} {index[pn.device]} {ar_id}"
287
+ f" {tb.ms_to_ns(pn.cycle_ms)} {pn.hold} {tb.ms_to_ns(pn.delay_ms)}"
288
+ f" {pn_frame_size(pn.outputs)} {pn_frame_size(pn.inputs)}"
289
+ )
274
290
  for t, source_id in zip(scenario.traffic, source_ids(scenario), strict=True):
291
+ if isinstance(t, model.ProfinetAR):
292
+ continue
275
293
  if isinstance(t, model.Poll):
276
294
  if t.source in has_link:
277
295
  c = connection(t.source, t.slave, MODBUS_PORT)
@@ -331,6 +349,8 @@ def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
331
349
  ok = adapter and target.name in has_link
332
350
  elif metric == "broker_queue":
333
351
  ok = isinstance(target, model.MqttBrokerNode)
352
+ elif metric in ("pn_latency", "pn_jitter", "pn_watchdog_expiries"):
353
+ ok = isinstance(target, model.AdapterNode | model.ProfinetDeviceNode)
334
354
  elif metric == "bytes_sent":
335
355
  ok = adapter and target.name in has_link
336
356
  elif metric == "queue_depth":
@@ -374,14 +394,17 @@ def _metrics(
374
394
  t_ms = tb.ns_to_ms(t)
375
395
  if s.metric == "throughput":
376
396
  out.append((t_ms, (a - last) * 8 * tb.NS_PER_US / (t - last_t)))
377
- elif s.metric in ("latency", "modbus_latency"):
397
+ elif s.metric in ("latency", "modbus_latency", "pn_latency"):
378
398
  if b:
379
399
  out.append((t_ms, a / (b * tb.NS_PER_US)))
400
+ elif s.metric == "pn_jitter":
401
+ if b:
402
+ out.append((t_ms, a / tb.NS_PER_US))
380
403
  elif s.metric == "bytes_received":
381
404
  out.append((t_ms, a / 1_000_000))
382
405
  elif s.metric == "bytes_sent":
383
406
  out.append((t_ms, a // 8 / 1_000_000))
384
- elif s.metric in ("queue_depth", "broker_queue"):
407
+ elif s.metric in ("queue_depth", "broker_queue", "pn_watchdog_expiries"):
385
408
  out.append((t_ms, float(a)))
386
409
  elif s.metric == "utilization":
387
410
  out.append((t_ms, tb.quotient((a - last) * 100_000, s.speed * (t - last_t))))