smolpy 1.9.0__tar.gz → 1.9.1.dev4__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.
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/ci.yml +21 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/docker-image.yml +2 -1
- smolpy-1.9.1.dev4/.github/workflows/ns3-base.yml +86 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/PKG-INFO +2 -1
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/README.md +1 -0
- smolpy-1.9.1.dev4/docker/ns3-base/Dockerfile +50 -0
- smolpy-1.9.1.dev4/docker/ns3-base/smoke.cc +92 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0004-execution-backends.md +41 -6
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +1 -1
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/dsl-reference.md +1 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/roadmap.md +8 -3
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/backends.py +75 -1
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/cli.py +1 -1
- smolpy-1.9.1.dev4/src/smolpy/ns3/__init__.py +302 -0
- smolpy-1.9.1.dev4/src/smolpy/ns3/cpp/smol-ns3.cc +982 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/equivalence/scenarios.py +40 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_backends.py +8 -4
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_batch.py +1 -1
- smolpy-1.9.1.dev4/tests/test_ns3.py +127 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/dev-build.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/docs.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/github-release.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/publish.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/release.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.github/workflows/rust-wheels.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/.gitignore +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/LICENSE +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/__main__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/runner.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/scenarios.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/benchmarks/worker.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docker/Dockerfile +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docker/Dockerfile.dockerignore +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docker/smoke.smol +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0001-protocol-package-structure.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0003-smol-external-dsl.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0005-profinet-rt.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/benchmarks.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/dashboard.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/examples.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/index.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/language-reference.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/modbus.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/model-semantics.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/mqtt.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/profinet.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/scenario-model.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/simulation-engine.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/README.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example.smol +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_10_clients.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_12_clients.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_20_clients.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_file_transfer.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_modbus.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_mqtt.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_profinet.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_profinet.smol +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_staggered_transfer.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/examples/example_two_tier.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/mkdocs.yml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/pyproject.toml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/Cargo.lock +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/Cargo.toml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/Cargo.toml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/src/frames.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/src/lib.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/src/rng.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/src/scenario.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/src/sim.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smol-engine/src/timebase.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/Cargo.toml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/README.md +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/pyproject.toml +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/smoke_test.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/rust/smolpy-engine-rs/src/lib.rs +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/_worker.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/batch.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/adapter.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/batch.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/link.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/network.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/node.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/core/observation.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/ethernet/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/ethernet/switch.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/lang/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/lang/ast.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/lang/errors.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/lang/grammar.lark +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/lang/interpreter.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/lang/transformer.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/modbus/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/modbus/slave.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/model/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/model/frames.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/model/scenario.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/model/streams.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/model/timebase.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/model/validate.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/mqtt/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/mqtt/broker.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/profinet/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/profinet/device.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/sim/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/sim/engine.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/stats.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/viz/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/viz/dashboard.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/src/smolpy/viz/text_dashboard.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/equivalence/__init__.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/equivalence/harness.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/equivalence/test_equivalence.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/equivalence/test_rust_timebase.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_benchmarks.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_cli.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_dsl.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_engine_ir.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_lang.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_model.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_profinet.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_semantics.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_simulation.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_stats.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_sweep.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_timebase.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/tests/test_validate.py +0 -0
- {smolpy-1.9.0 → smolpy-1.9.1.dev4}/uv.lock +0 -0
|
@@ -100,3 +100,24 @@ jobs:
|
|
|
100
100
|
|
|
101
101
|
- name: Equivalence with SimPy (bit for bit)
|
|
102
102
|
run: uv run --no-sync pytest tests/equivalence tests/test_backends.py -v --tb=short
|
|
103
|
+
|
|
104
|
+
ns3:
|
|
105
|
+
name: ns-3 backend
|
|
106
|
+
runs-on: ubuntu-latest
|
|
107
|
+
# the pinned ns-3 build (ns3-base.yml): NS3_HOME is set, g++ is there
|
|
108
|
+
container: ghcr.io/jwszolek/smolpy-ns3-base:3.49
|
|
109
|
+
|
|
110
|
+
steps:
|
|
111
|
+
- uses: actions/checkout@v4
|
|
112
|
+
with:
|
|
113
|
+
fetch-depth: 0 # hatch-vcs reads the version from git
|
|
114
|
+
|
|
115
|
+
- name: Install smolpy
|
|
116
|
+
run: python -m pip install --quiet --root-user-action=ignore -e . pytest
|
|
117
|
+
|
|
118
|
+
# makes sure the tests below run the ns3 backend instead of skipping it
|
|
119
|
+
- name: Check that the ns3 backend is installed
|
|
120
|
+
run: python -c "from smolpy import backends; backends.get('ns3'); print(backends.installed())"
|
|
121
|
+
|
|
122
|
+
- name: Equivalence with SimPy
|
|
123
|
+
run: python -m pytest tests/equivalence tests/test_ns3.py -k ns3 -v --tb=short
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: ns-3 base image
|
|
2
|
+
|
|
3
|
+
# ghcr.io/jwszolek/smolpy-ns3-base:<ns-3 version> (ADR-0004, Container
|
|
4
|
+
# images): the pinned ns-3 release, built once. It is rebuilt only when its
|
|
5
|
+
# Dockerfile changes, which is how the pinned release changes, so releases
|
|
6
|
+
# never build ns-3. linux/amd64 for now; linux/arm64 is to follow on a native
|
|
7
|
+
# runner, as an emulated build of ns-3 would take hours.
|
|
8
|
+
#
|
|
9
|
+
# Every build is tested before it is pushed: a scratch program, as the ns-3
|
|
10
|
+
# backend's generated scenarios will be, built and run against it.
|
|
11
|
+
#
|
|
12
|
+
# - On a pull request that changes it: build and test, push nothing.
|
|
13
|
+
# - After the merge to main, or run by hand: build, test and push.
|
|
14
|
+
|
|
15
|
+
on:
|
|
16
|
+
push:
|
|
17
|
+
branches:
|
|
18
|
+
- main
|
|
19
|
+
paths:
|
|
20
|
+
- "docker/ns3-base/**"
|
|
21
|
+
- ".github/workflows/ns3-base.yml"
|
|
22
|
+
pull_request:
|
|
23
|
+
paths:
|
|
24
|
+
- "docker/ns3-base/**"
|
|
25
|
+
- ".github/workflows/ns3-base.yml"
|
|
26
|
+
workflow_dispatch:
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
image:
|
|
30
|
+
name: ns-3 base image
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
timeout-minutes: 120
|
|
33
|
+
permissions:
|
|
34
|
+
contents: read
|
|
35
|
+
packages: write # push to ghcr.io
|
|
36
|
+
|
|
37
|
+
env:
|
|
38
|
+
IMAGE: ghcr.io/${{ github.repository_owner }}/smolpy-ns3-base
|
|
39
|
+
PUSH: ${{ github.event_name != 'pull_request' }}
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- name: The pinned ns-3 release
|
|
45
|
+
id: v
|
|
46
|
+
run: |
|
|
47
|
+
VERSION=$(sed -nE 's/^ARG NS3_VERSION=(.+)$/\1/p' docker/ns3-base/Dockerfile)
|
|
48
|
+
test -n "$VERSION"
|
|
49
|
+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
50
|
+
echo "ns-3 $VERSION"
|
|
51
|
+
|
|
52
|
+
- uses: docker/setup-buildx-action@v3
|
|
53
|
+
|
|
54
|
+
# the layers of an unchanged ns-3 build come from the cache
|
|
55
|
+
- name: Build
|
|
56
|
+
uses: docker/build-push-action@v6
|
|
57
|
+
with:
|
|
58
|
+
context: docker/ns3-base
|
|
59
|
+
platforms: linux/amd64
|
|
60
|
+
load: true
|
|
61
|
+
tags: ns3-base:test
|
|
62
|
+
cache-from: type=gha,scope=ns3-base
|
|
63
|
+
cache-to: type=gha,scope=ns3-base,mode=max
|
|
64
|
+
|
|
65
|
+
- name: Test with a scratch program
|
|
66
|
+
run: |
|
|
67
|
+
docker run --rm -v "$PWD/docker/ns3-base/smoke.cc:/opt/ns-3/scratch/smoke.cc:ro" \
|
|
68
|
+
ns3-base:test ./ns3 run smoke
|
|
69
|
+
docker image ls ns3-base:test
|
|
70
|
+
|
|
71
|
+
- name: Log in to ghcr.io
|
|
72
|
+
if: ${{ env.PUSH == 'true' }}
|
|
73
|
+
uses: docker/login-action@v3
|
|
74
|
+
with:
|
|
75
|
+
registry: ghcr.io
|
|
76
|
+
username: ${{ github.actor }}
|
|
77
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
78
|
+
|
|
79
|
+
- name: Push
|
|
80
|
+
if: ${{ env.PUSH == 'true' }}
|
|
81
|
+
env:
|
|
82
|
+
VERSION: ${{ steps.v.outputs.version }}
|
|
83
|
+
run: |
|
|
84
|
+
docker tag ns3-base:test "$IMAGE:$VERSION"
|
|
85
|
+
docker push "$IMAGE:$VERSION"
|
|
86
|
+
echo "Pushed $IMAGE:$VERSION" >> "$GITHUB_STEP_SUMMARY"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: smolpy
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.1.dev4
|
|
4
4
|
Summary: Network simulation DSL and discrete-event simulator
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -482,6 +482,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
|
|
|
482
482
|
|---|---|---|---|---|
|
|
483
483
|
| `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
|
|
484
484
|
| `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/UDP stack, from C++ | Ethernet so far: adapters, switches, constant flows without priorities; bit-exact with SimPy there | 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` |
|
|
485
486
|
|
|
486
487
|
```python
|
|
487
488
|
result = net.simulate(duration=60_000, backend="rust") # one run
|
|
@@ -454,6 +454,7 @@ Every simulation goes through the same path. The Python API and `.smol` files bu
|
|
|
454
454
|
|---|---|---|---|---|
|
|
455
455
|
| `simpy` (default) | Python, SimPy | the whole model, the live and text dashboards | reference | included |
|
|
456
456
|
| `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/UDP stack, from C++ | Ethernet so far: adapters, switches, constant flows without priorities; bit-exact with SimPy there | 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` |
|
|
457
458
|
|
|
458
459
|
```python
|
|
459
460
|
result = net.simulate(duration=60_000, backend="rust") # one run
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# The ns-3 base image: ghcr.io/jwszolek/smolpy-ns3-base:<ns-3 version>
|
|
2
|
+
# (ADR-0004, Container images). Built by .github/workflows/ns3-base.yml.
|
|
3
|
+
#
|
|
4
|
+
# It holds the pinned ns-3 release, built once: the release profile, without
|
|
5
|
+
# examples, tests or Python bindings, and only the modules SMOLPy's scenarios
|
|
6
|
+
# need. Not the optimized profile: it compiles with -march=native, for the CPU
|
|
7
|
+
# of the machine that builds the image, which another CPU may not run.
|
|
8
|
+
#
|
|
9
|
+
# The toolchain stays in the image, because the ns-3 backend builds each
|
|
10
|
+
# generated scenario as a scratch program against this build. The SMOLPy
|
|
11
|
+
# image with ns-3, <version>-ns3, is built on top of it at each release.
|
|
12
|
+
#
|
|
13
|
+
# ns-3 is licensed under GPLv2, so this image is distributed under its terms.
|
|
14
|
+
|
|
15
|
+
FROM python:3.12-slim-bookworm
|
|
16
|
+
|
|
17
|
+
# Changing the pinned release: a new version, its tag's commit
|
|
18
|
+
# (git ls-remote https://gitlab.com/nsnam/ns-3-dev.git refs/tags/ns-3.<n>^{})
|
|
19
|
+
# and the image tag in ns3-base.yml follow from these.
|
|
20
|
+
ARG NS3_VERSION=3.49
|
|
21
|
+
ARG NS3_COMMIT=418210e8914e9f6bcb5cddbcc94a2cecb7853b68
|
|
22
|
+
ARG NS3_MODULES="core;network;internet;applications;csma;bridge;traffic-control;stats"
|
|
23
|
+
|
|
24
|
+
LABEL org.opencontainers.image.title="ns-3 ${NS3_VERSION} for SMOLPy" \
|
|
25
|
+
org.opencontainers.image.description="The pinned ns-3 release, built for SMOLPy's ns-3 backend" \
|
|
26
|
+
org.opencontainers.image.source="https://github.com/jwszolek/SMOLPy" \
|
|
27
|
+
org.opencontainers.image.licenses="GPL-2.0-only" \
|
|
28
|
+
org.opencontainers.image.version="${NS3_VERSION}" \
|
|
29
|
+
org.nsnam.ns3.source="https://gitlab.com/nsnam/ns-3-dev/-/tree/ns-${NS3_VERSION}" \
|
|
30
|
+
org.nsnam.ns3.commit="${NS3_COMMIT}"
|
|
31
|
+
|
|
32
|
+
# g++ 12 and CMake 3.25 of Debian 12 meet ns-3.49's minimums (g++ 11.1, CMake 3.25)
|
|
33
|
+
# hadolint ignore=DL3008
|
|
34
|
+
RUN apt-get update \
|
|
35
|
+
&& apt-get install -y --no-install-recommends g++ cmake ninja-build git ca-certificates \
|
|
36
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
37
|
+
|
|
38
|
+
RUN git clone --quiet --depth 1 --branch "ns-${NS3_VERSION}" \
|
|
39
|
+
https://gitlab.com/nsnam/ns-3-dev.git /opt/ns-3 \
|
|
40
|
+
&& test "$(git -C /opt/ns-3 rev-parse HEAD)" = "${NS3_COMMIT}" \
|
|
41
|
+
&& rm -rf /opt/ns-3/.git
|
|
42
|
+
|
|
43
|
+
WORKDIR /opt/ns-3
|
|
44
|
+
RUN ./ns3 configure --build-profile=release -G Ninja \
|
|
45
|
+
--disable-examples --disable-tests --disable-python-bindings --disable-werror \
|
|
46
|
+
--enable-modules="${NS3_MODULES}" \
|
|
47
|
+
&& ./ns3 build
|
|
48
|
+
|
|
49
|
+
ENV NS3_HOME=/opt/ns-3 \
|
|
50
|
+
NS3_VERSION=${NS3_VERSION}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Smoke test of the ns-3 base image (ADR-0004, Container images).
|
|
2
|
+
//
|
|
3
|
+
// Built as a scratch program, as the ns-3 backend's generated scenarios will
|
|
4
|
+
// be: two hosts on CSMA links to a learning bridge, the SMOL wire model of a
|
|
5
|
+
// link (data rate, propagation delay, a 20 B inter-frame gap), neighbour
|
|
6
|
+
// caches filled before the run, and a UDP echo across the bridge. Exits
|
|
7
|
+
// non-zero unless every echo comes back.
|
|
8
|
+
//
|
|
9
|
+
// cp smoke.cc $NS3_HOME/scratch/ && $NS3_HOME/ns3 run smoke
|
|
10
|
+
|
|
11
|
+
#include "ns3/applications-module.h"
|
|
12
|
+
#include "ns3/bridge-module.h"
|
|
13
|
+
#include "ns3/core-module.h"
|
|
14
|
+
#include "ns3/csma-module.h"
|
|
15
|
+
#include "ns3/internet-module.h"
|
|
16
|
+
#include "ns3/network-module.h"
|
|
17
|
+
|
|
18
|
+
#include <iostream>
|
|
19
|
+
|
|
20
|
+
using namespace ns3;
|
|
21
|
+
|
|
22
|
+
static uint32_t g_echoes = 0;
|
|
23
|
+
|
|
24
|
+
static void
|
|
25
|
+
OnEcho(Ptr<const Packet>)
|
|
26
|
+
{
|
|
27
|
+
++g_echoes;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
int
|
|
31
|
+
main(int argc, char* argv[])
|
|
32
|
+
{
|
|
33
|
+
const uint32_t packets = 10;
|
|
34
|
+
Time::SetResolution(Time::NS); // the SMOL clock: integer nanoseconds
|
|
35
|
+
|
|
36
|
+
NodeContainer hosts;
|
|
37
|
+
hosts.Create(2);
|
|
38
|
+
Ptr<Node> sw = CreateObject<Node>();
|
|
39
|
+
|
|
40
|
+
// one CSMA channel per link: 100 Mb/s, 10 m at 2e8 m/s
|
|
41
|
+
CsmaHelper csma;
|
|
42
|
+
csma.SetChannelAttribute("DataRate", DataRateValue(DataRate("100Mbps")));
|
|
43
|
+
csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(50)));
|
|
44
|
+
|
|
45
|
+
NetDeviceContainer hostDevices;
|
|
46
|
+
NetDeviceContainer switchPorts;
|
|
47
|
+
for (uint32_t i = 0; i < hosts.GetN(); ++i)
|
|
48
|
+
{
|
|
49
|
+
NetDeviceContainer link = csma.Install(NodeContainer(hosts.Get(i), sw));
|
|
50
|
+
// CSMA attaches with a 12 B gap and no preamble: 20 B at 100 Mb/s
|
|
51
|
+
// stand for both (ADR-0010). The gap is not an attribute, so it is
|
|
52
|
+
// set on each device once it is attached.
|
|
53
|
+
for (uint32_t d = 0; d < link.GetN(); ++d)
|
|
54
|
+
{
|
|
55
|
+
DynamicCast<CsmaNetDevice>(link.Get(d))->SetInterframeGap(NanoSeconds(1600));
|
|
56
|
+
}
|
|
57
|
+
hostDevices.Add(link.Get(0));
|
|
58
|
+
switchPorts.Add(link.Get(1));
|
|
59
|
+
}
|
|
60
|
+
BridgeHelper bridge;
|
|
61
|
+
bridge.Install(sw, switchPorts);
|
|
62
|
+
|
|
63
|
+
InternetStackHelper internet;
|
|
64
|
+
internet.Install(hosts);
|
|
65
|
+
Ipv4AddressHelper ipv4;
|
|
66
|
+
ipv4.SetBase("10.0.0.0", "255.255.255.0");
|
|
67
|
+
Ipv4InterfaceContainer addresses = ipv4.Assign(hostDevices);
|
|
68
|
+
// SMOL models no ARP: the neighbour caches start full, or the first
|
|
69
|
+
// frames would wait up to 10 ms for a jittered request (RequestJitter)
|
|
70
|
+
NeighborCacheHelper neighbours;
|
|
71
|
+
neighbours.PopulateNeighborCache();
|
|
72
|
+
|
|
73
|
+
UdpEchoServerHelper server(9);
|
|
74
|
+
ApplicationContainer serverApp = server.Install(hosts.Get(1));
|
|
75
|
+
serverApp.Start(MilliSeconds(0));
|
|
76
|
+
|
|
77
|
+
UdpEchoClientHelper client(addresses.GetAddress(1), 9);
|
|
78
|
+
client.SetAttribute("MaxPackets", UintegerValue(packets));
|
|
79
|
+
client.SetAttribute("Interval", TimeValue(MilliSeconds(1)));
|
|
80
|
+
client.SetAttribute("PacketSize", UintegerValue(512));
|
|
81
|
+
ApplicationContainer clientApp = client.Install(hosts.Get(0));
|
|
82
|
+
clientApp.Start(MilliSeconds(1));
|
|
83
|
+
Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::UdpEchoClient/Rx",
|
|
84
|
+
MakeCallback(&OnEcho));
|
|
85
|
+
|
|
86
|
+
Simulator::Stop(MilliSeconds(100));
|
|
87
|
+
Simulator::Run();
|
|
88
|
+
Simulator::Destroy();
|
|
89
|
+
|
|
90
|
+
std::cout << "ns-3 smoke test: " << g_echoes << " of " << packets << " echoes" << std::endl;
|
|
91
|
+
return g_echoes == packets ? 0 : 1;
|
|
92
|
+
}
|
|
@@ -100,7 +100,11 @@ smolpy backends # list backends and their capabiliti
|
|
|
100
100
|
|
|
101
101
|
**Execution.** The backend locates an ns-3 source tree via `--ns3-home` or the `NS3_HOME` environment variable, places the generated scenario and the SMOL C++ module under ns-3's `scratch/` area, builds and runs it with ns-3's build tool, and reads the results. A missing or incompatible ns-3 installation produces a clear error, not a traceback. The supported ns-3 release is pinned and documented; generated scenarios are kept on request (`--keep-generated`) for inspection and archiving.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
*Amended 2026-11-16 (as built):* the scenario is not code-generated. `smol-ns3`, one C++ program (`src/smolpy/ns3/cpp/smol-ns3.cc`), is compiled once per ns-3 build and kept in the user's cache. For each run, the Python side lowers the scenario to plain lines of integers: every time in integer nanoseconds, every speed and period as an exact rational. The program reads them and runs.
|
|
104
|
+
- **Why.** A run does not build anything or write into the ns-3 tree. So runs are parallel and fast, and the images can run as an ordinary user.
|
|
105
|
+
- **Archiving.** The scenario JSON, the lowered input and the program's source, all in the repository, fix a run as exactly as generated code would.
|
|
106
|
+
|
|
107
|
+
**Results interchange.** ~~Samplers in the C++ module write the same long CSV format that `SimulationResult.export()` already produces (`time_ms,metric,value`).~~ *As built:* at each sample instant, the samplers write raw integer counters: bytes, bits and frames, the sum and count of latencies, and queue lengths. The Python side computes every metric from them with the reference engine's formulas, so each value is rounded once, as there. The backend loads the result into a regular `SimulationResult`, so `report()`, `export()` and `--output` work identically for both backends.
|
|
104
108
|
|
|
105
109
|
**Seed.** The `simulate` statement's `seed` maps to ns-3's RNG seed/run configuration, so seeded runs are reproducible on both backends.
|
|
106
110
|
|
|
@@ -111,11 +115,11 @@ smolpy backends # list backends and their capabiliti
|
|
|
111
115
|
| SMOL | ns-3 |
|
|
112
116
|
|---|---|
|
|
113
117
|
| `adapter`, `mqtt_broker`, `modbus_slave` | Node with Internet stack (IPv4 address from `ip`) |
|
|
114
|
-
| `switch` (store-and-forward) | Node with a learning bridge over one device per port |
|
|
118
|
+
| `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. |
|
|
115
119
|
| `switch mode=cut-through` | **unsupported** — capability error |
|
|
116
120
|
| `hub` | Shared CSMA channel *(hubs and `collision_rate` were later removed; see [Model Semantics](../model-semantics.md#open-issues), open issue 3)* |
|
|
117
|
-
| `link speed= length=` | Device data rate = `speed`; channel delay = `length / 2·10⁸ m/s` (same propagation constant as `core/link.py`). *Since ADR-0010:*
|
|
118
|
-
| `flow` | UDP application; payload sized so the on-wire frame matches `size` (constant, Poisson, bursty patterns; `imix` sizes) |
|
|
121
|
+
| `link speed= length=` | *Amended 2026-11-16: SMOL's own full-duplex Ethernet device and channel, not CSMA; see "Link model on ns-3" below.* Device data rate = `speed`; channel delay = `length / 2·10⁸ m/s` (same propagation constant as `core/link.py`). *Since ADR-0010:* inter-frame gap = the time of 20 B at `speed` (preamble, SFD and gap, which CSMA does not model otherwise); CSMA adds the Ethernet header and FCS itself. *In ns-3.49 the gap is not an attribute: `Attach()` sets 12 B, so the generator calls `CsmaNetDevice::SetInterframeGap()` on each device after installing it.* |
|
|
122
|
+
| `flow` | UDP application; payload sized so the on-wire frame matches `size` (constant, Poisson, bursty patterns; `imix` sizes). *As built:* the payload is `size` minus 46 B (Ethernet 18, IPv4 20, UDP 8), sent to port 9 of the destination, where a socket discards it. |
|
|
119
123
|
| `publish` / `route` | MQTT publisher / broker Applications over one persistent TCP connection per client; QoS 1 sends PUBACK |
|
|
120
124
|
| `poll` | Modbus TCP master / slave Applications over one persistent TCP connection per master–slave pair (port 502), MBAP transaction IDs, Read Holding Registers (FC 03) |
|
|
121
125
|
| `observe` | Periodic sampler writing CSV rows |
|
|
@@ -202,6 +206,37 @@ docker run --rm -v "$PWD:/work" -w /work ghcr.io/jwszolek/smolpy:latest-ns3 run
|
|
|
202
206
|
- The image without ns-3 contains no GPL code.
|
|
203
207
|
- **Not a replacement for pip.** `pip install smolpy smolpy-engine-rs` stays the main way to install SMOLPy. The images are for ns-3, for running without a Python setup, and for archiving.
|
|
204
208
|
|
|
209
|
+
**Link model on ns-3** *(decided 2026-11-16)*
|
|
210
|
+
|
|
211
|
+
ns-3.49's CSMA is a shared bus: the two ends of a link wait for each other, and a busy link backs off. SMOLPy's links are full duplex. With CSMA, ns-3 would differ from the other engines because of the link model, not because of the TCP/IP stack it is there to bring.
|
|
212
|
+
|
|
213
|
+
- **Decision.** The ns-3 backend uses SMOL's own Ethernet device and channel, from the SMOL C++ module.
|
|
214
|
+
- The device is full duplex, with one unbounded egress queue per port.
|
|
215
|
+
- A frame is its IP packet plus 18 B, at least 64 B.
|
|
216
|
+
- It occupies the wire for preamble, SFD and frame, and the next frame waits for the 12 B gap (ADR-0010).
|
|
217
|
+
- Times are rounded as in Model Semantics §1.
|
|
218
|
+
- **IP on top.** IPv4 runs on the device with a /32 address and every destination on the link. IPv6 is not installed, so there are no router solicitations or other IPv6 traffic. The neighbour caches start full, because SMOL models no ARP.
|
|
219
|
+
- **What ns-3 contributes** is its IPv4/UDP stack now, and its TCP stack for Modbus and MQTT later. The differences that remain between engines are the protocol stack's, which is what the comparison is for.
|
|
220
|
+
- **Options rejected.**
|
|
221
|
+
- **CSMA as planned.** Its differences from the other engines would come from half duplex.
|
|
222
|
+
- **`SimpleNetDevice`.** It is full duplex, but it counts neither the Ethernet header and FCS nor the preamble and gap: about 38 B per frame too few.
|
|
223
|
+
|
|
224
|
+
**First results** *(2026-11-16)*. Constant flows of fixed-size frames without priorities are in scope so far. The `line` and `bridging` scenarios, and `switching` with its priorities set to 0, give SimPy's results bit for bit, through ns-3's IPv4/UDP stack. `bridging` has a flooding learning core, a hairpin at a converged switch, jumbo frames and a saturated 10 Mb/s link. So the deterministic suite compares ns-3 exactly, like Rust. ADR-0009's high-fidelity rules remain for TCP.
|
|
225
|
+
|
|
226
|
+
**The ns-3 base image, as built** *(2026-11-16)*:
|
|
227
|
+
- `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`.
|
|
228
|
+
- **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.
|
|
229
|
+
- **Build:**
|
|
230
|
+
- The `release` profile, without examples, tests or Python bindings.
|
|
231
|
+
- The modules `core`, `network`, `internet`, `applications`, `csma`, `bridge`, `traffic-control` and `stats`, plus what they need.
|
|
232
|
+
- Not the `optimized` profile: it compiles with `-march=native`, and a binary built for the CPU of the CI runner may not run on another one.
|
|
233
|
+
- A local build with 15 threads takes 80 s.
|
|
234
|
+
- **Test:** each build compiles and runs `docker/ns3-base/smoke.cc` as a scratch program against the prebuilt modules. The program is two hosts on CSMA links to a bridge, with the SMOL wire model and a UDP echo.
|
|
235
|
+
- **Findings for the generator** (step 3):
|
|
236
|
+
- **Scratch programs work.** A scenario placed in `scratch/` is built against the prebuilt modules, so no contrib module is needed.
|
|
237
|
+
- **The inter-frame gap** is set with `SetInterframeGap()`, as in the mapping table.
|
|
238
|
+
- **Neighbour caches must start full** (`NeighborCacheHelper::PopulateNeighborCache()`). SMOL models no ARP. Without the full caches, ns-3 delays its first ARP request by up to 10 ms (`ArpL3Protocol::RequestJitter`), and its queue of 3 pending packets drops the rest.
|
|
239
|
+
|
|
205
240
|
### Documentation
|
|
206
241
|
|
|
207
242
|
- `docs/backends.md` — backend concept, installing ns-3, `--backend`, capability tables, known fidelity differences.
|
|
@@ -211,9 +246,9 @@ docker run --rm -v "$PWD:/work" -w /work ghcr.io/jwszolek/smolpy:latest-ns3 run
|
|
|
211
246
|
|
|
212
247
|
- Exact behaviour of ns-3's CSMA model versus SimPy's collision approximation, to decide whether `hub` support should be limited further. *(Resolved: hubs were removed.)*
|
|
213
248
|
- How ns-3 queue lengths should be sampled so that `queue_depth` is comparable to SimPy's per-port frame count.
|
|
214
|
-
- Whether the pinned ns-3 release's build tool supports building scratch programs with an extra module cleanly, or the module should be installed as a contrib module.
|
|
249
|
+
- Whether the pinned ns-3 release's build tool supports building scratch programs with an extra module cleanly, or the module should be installed as a contrib module. *(Resolved: scratch programs build against the prebuilt modules; see the base image above.)*
|
|
215
250
|
- The size of the `-ns3` image, and whether to build ns-3 in its `optimized` profile only, without examples and tests, to keep it small.
|
|
216
|
-
- Whether GitHub's hosted runners can build the ns-3 base image for `linux/arm64` in reasonable time, or that platform needs a native arm64 runner or is offered for `amd64` only at first.
|
|
251
|
+
- Whether GitHub's hosted runners can build the ns-3 base image for `linux/arm64` in reasonable time, or that platform needs a native arm64 runner or is offered for `amd64` only at first. *(Decided: `amd64` only at first; `arm64` on a native runner later.)*
|
|
217
252
|
|
|
218
253
|
---
|
|
219
254
|
|
{smolpy-1.9.0 → smolpy-1.9.1.dev4}/docs/adr/0009-batch-execution-and-cross-backend-validation.md
RENAMED
|
@@ -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. |
|
|
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. These rules remain for TCP, where ns-3's stack is meant to differ. |
|
|
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,6 +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 adapters, switches and constant flows of fixed-size frames without 802.1Q priorities, with the Ethernet metrics, on ns-3's IPv4/UDP stack. 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
169
|
|
|
169
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`.
|
|
170
171
|
- **A missing backend is an error.** When a backend is not installed, selecting it raises `BackendUnavailable` with the install command.
|
|
@@ -172,10 +172,15 @@ 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:**
|
|
175
|
+
**Status:** steps 1 and 2 of 3 done, and step 3 has begun.
|
|
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
|
-
2. **The ns-3 base image.**
|
|
178
|
-
3. **The ns-3 backend.**
|
|
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
|
+
3. **The ns-3 backend.**
|
|
179
|
+
- **Ethernet: done.** `backend="ns3"` runs adapters, switches and constant flows of fixed-size frames without priorities, with the six Ethernet metrics, on ns-3's IPv4/UDP stack.
|
|
180
|
+
- It runs over SMOL's own full-duplex Ethernet device, because ns-3's CSMA is half duplex (ADR-0004).
|
|
181
|
+
- `line`, `bridging` and `switching` without priorities are bit-exact with SimPy.
|
|
182
|
+
- CI runs the backend in the base image.
|
|
183
|
+
- **Next:** 802.1Q priorities, random patterns and IMIX, then Modbus and MQTT over TCP, then PROFINET.
|
|
179
184
|
|
|
180
185
|
**Exit criteria:**
|
|
181
186
|
|
|
@@ -12,6 +12,8 @@ silently.
|
|
|
12
12
|
own capabilities, so this module never claims more than the engine
|
|
13
13
|
supports, and the Scenario IR version it reads, which must be this
|
|
14
14
|
smolpy's.
|
|
15
|
+
- ``ns3``: ns-3's IPv4/UDP stack on SMOL's own full-duplex Ethernet
|
|
16
|
+
(ADR-0004, ``smolpy.ns3``), where ``NS3_HOME`` names an ns-3 build.
|
|
15
17
|
|
|
16
18
|
The Rust module's contract is::
|
|
17
19
|
|
|
@@ -51,6 +53,7 @@ class Capabilities:
|
|
|
51
53
|
patterns: frozenset[str] # of flows
|
|
52
54
|
metrics: frozenset[str]
|
|
53
55
|
features: frozenset[str] = frozenset() # "imix": IMIX frame sizes
|
|
56
|
+
priorities: bool = True # 802.1Q priorities above 0 on flows
|
|
54
57
|
half_duplex: bool = False
|
|
55
58
|
dashboards: bool = False # the live and text modes of simulate()
|
|
56
59
|
notes: dict[str, str] = field(default_factory=dict) # kind -> "not yet" detail
|
|
@@ -140,6 +143,7 @@ class RustBackend:
|
|
|
140
143
|
patterns=frozenset(caps["patterns"]),
|
|
141
144
|
metrics=frozenset(caps["metrics"]),
|
|
142
145
|
features=frozenset(caps.get("features", ())),
|
|
146
|
+
priorities=bool(caps.get("priorities", True)),
|
|
143
147
|
half_duplex=bool(caps.get("half_duplex", False)),
|
|
144
148
|
dashboards=False,
|
|
145
149
|
notes=dict(caps.get("notes", {})),
|
|
@@ -153,7 +157,75 @@ class RustBackend:
|
|
|
153
157
|
return SimulationResult(dict(metrics), scenario, stats)
|
|
154
158
|
|
|
155
159
|
|
|
156
|
-
|
|
160
|
+
class Ns3Backend:
|
|
161
|
+
"""ns-3 (ADR-0004, ``smolpy.ns3``), where ``NS3_HOME`` names an ns-3 build.
|
|
162
|
+
|
|
163
|
+
So far it runs Ethernet with constant flows of fixed-size frames, without
|
|
164
|
+
802.1Q priorities; the protocols and random traffic follow in Phase 6.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
name = "ns3"
|
|
168
|
+
install = (
|
|
169
|
+
"set NS3_HOME to a built ns-3 3.49 tree, or run in the image"
|
|
170
|
+
" ghcr.io/jwszolek/smolpy-ns3-base"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
def _locate(self) -> None:
|
|
174
|
+
from smolpy.ns3 import Ns3Unavailable, locate
|
|
175
|
+
|
|
176
|
+
try:
|
|
177
|
+
locate()
|
|
178
|
+
except Ns3Unavailable as exc:
|
|
179
|
+
raise BackendUnavailable(
|
|
180
|
+
f"the ns3 backend is not available: {exc} ({self.install})"
|
|
181
|
+
) from exc
|
|
182
|
+
|
|
183
|
+
def available(self) -> bool:
|
|
184
|
+
try:
|
|
185
|
+
self._locate()
|
|
186
|
+
except BackendUnavailable:
|
|
187
|
+
return False
|
|
188
|
+
return True
|
|
189
|
+
|
|
190
|
+
def capabilities(self) -> Capabilities:
|
|
191
|
+
self._locate()
|
|
192
|
+
later = "planned for Phase 6"
|
|
193
|
+
return Capabilities(
|
|
194
|
+
nodes=frozenset({"adapter", "switch"}),
|
|
195
|
+
traffic=frozenset({"flow"}),
|
|
196
|
+
patterns=frozenset({"constant"}),
|
|
197
|
+
metrics=frozenset(
|
|
198
|
+
{
|
|
199
|
+
"throughput",
|
|
200
|
+
"latency",
|
|
201
|
+
"bytes_sent",
|
|
202
|
+
"bytes_received",
|
|
203
|
+
"queue_depth",
|
|
204
|
+
"utilization",
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
priorities=False,
|
|
208
|
+
notes={
|
|
209
|
+
kind: later
|
|
210
|
+
for kind in (
|
|
211
|
+
"mqtt_broker",
|
|
212
|
+
"modbus_slave",
|
|
213
|
+
"profinet_device",
|
|
214
|
+
"publish",
|
|
215
|
+
"route",
|
|
216
|
+
"poll",
|
|
217
|
+
"profinet_ar",
|
|
218
|
+
)
|
|
219
|
+
},
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def run(self, scenario: Scenario) -> SimulationResult:
|
|
223
|
+
from smolpy import ns3
|
|
224
|
+
|
|
225
|
+
return ns3.run(scenario)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
REGISTRY: dict[str, Backend] = {b.name: b for b in (SimPyBackend(), RustBackend(), Ns3Backend())}
|
|
157
229
|
|
|
158
230
|
|
|
159
231
|
def get(name: str) -> Backend:
|
|
@@ -221,6 +293,8 @@ def check(scenario: Scenario, backend: str = DEFAULT, *, dashboard: bool = False
|
|
|
221
293
|
raise unsupported(t, f"pattern {pattern!r}", ("traffic", i))
|
|
222
294
|
if getattr(t, "size", None) == "imix" and "imix" not in caps.features:
|
|
223
295
|
raise unsupported(t, "IMIX frame sizes", ("traffic", i))
|
|
296
|
+
if getattr(t, "priority", 0) > 0 and not caps.priorities:
|
|
297
|
+
raise unsupported(t, "802.1Q priorities", ("traffic", i))
|
|
224
298
|
for i, o in enumerate(scenario.observations):
|
|
225
299
|
if o.metric not in caps.metrics:
|
|
226
300
|
raise unsupported(o, f"metric {o.metric!r}", ("observations", i))
|
|
@@ -294,7 +294,7 @@ def _add_run_options(parser: argparse.ArgumentParser) -> None:
|
|
|
294
294
|
"--backend",
|
|
295
295
|
default=None,
|
|
296
296
|
metavar="NAME",
|
|
297
|
-
help="Run a .smol file on backend NAME: simpy (default) or
|
|
297
|
+
help="Run a .smol file on backend NAME: simpy (default), rust or ns3",
|
|
298
298
|
)
|
|
299
299
|
|
|
300
300
|
|