smolpy 1.9.1.dev4__tar.gz → 1.9.1.dev6__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.1.dev4 → smolpy-1.9.1.dev6}/PKG-INFO +2 -2
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/README.md +1 -1
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0004-execution-backends.md +9 -2
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0009-batch-execution-and-cross-backend-validation.md +1 -1
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/dsl-reference.md +1 -1
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/roadmap.md +4 -3
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/backends.py +4 -4
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/ns3/__init__.py +71 -7
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/ns3/cpp/smol-ns3.cc +192 -35
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/equivalence/test_equivalence.py +16 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_ns3.py +53 -7
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/ci.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/dev-build.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/docker-image.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/docs.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/github-release.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/ns3-base.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/publish.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/release.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.github/workflows/rust-wheels.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/.gitignore +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/LICENSE +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/__main__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-13-0921-simpy-jaws-zbook-baseline.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-13-1527-simpy-jaws-zbook-optimised.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-13-2116-simpy-jaws-zbook-research-batch.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-13-2119-simpy-jaws-zbook-research-b4.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-15-1255-rust-jaws-zbook-stop-criterion.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-15-1333-rust-jaws-zbook-research-b4.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/results/2026-11-15-1346-rust-jaws-zbook-research-batch.json +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/runner.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/scenarios.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/benchmarks/worker.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docker/Dockerfile +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docker/Dockerfile.dockerignore +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docker/ns3-base/Dockerfile +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docker/ns3-base/smoke.cc +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docker/smoke.smol +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0001-protocol-package-structure.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0002-modbus-tcp-implementation.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0003-smol-external-dsl.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0005-profinet-rt.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0006-profiling-and-baseline-benchmark.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0007-execution-independent-scenario-model.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0008-rust-des-engine-mvp.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/adr/0010-ethernet-frames-on-the-wire.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/benchmarks.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/dashboard.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/examples.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/index.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/language-reference.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/modbus.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/model-semantics.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/mqtt.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/profinet.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/scenario-model.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/docs/simulation-engine.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/README.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example.smol +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_10_clients.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_12_clients.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_20_clients.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_file_transfer.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_modbus.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_mqtt.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_profinet.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_profinet.smol +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_staggered_transfer.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/examples/example_two_tier.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/mkdocs.yml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/pyproject.toml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/Cargo.lock +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/Cargo.toml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/Cargo.toml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/src/frames.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/src/lib.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/src/rng.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/src/scenario.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/src/sim.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smol-engine/src/timebase.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smolpy-engine-rs/Cargo.toml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smolpy-engine-rs/README.md +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smolpy-engine-rs/pyproject.toml +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smolpy-engine-rs/smoke_test.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/rust/smolpy-engine-rs/src/lib.rs +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/_worker.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/batch.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/cli.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/adapter.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/batch.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/link.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/network.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/node.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/core/observation.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/ethernet/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/ethernet/switch.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/lang/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/lang/ast.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/lang/errors.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/lang/grammar.lark +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/lang/interpreter.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/lang/transformer.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/modbus/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/modbus/slave.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/model/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/model/frames.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/model/scenario.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/model/streams.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/model/timebase.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/model/validate.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/mqtt/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/mqtt/broker.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/profinet/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/profinet/device.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/sim/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/sim/engine.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/stats.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/viz/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/viz/dashboard.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/src/smolpy/viz/text_dashboard.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/equivalence/__init__.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/equivalence/harness.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/equivalence/scenarios.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/equivalence/test_rust_timebase.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_backends.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_batch.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_benchmarks.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_cli.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_dsl.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_engine_ir.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_lang.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_model.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_profinet.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_semantics.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_simulation.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_stats.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_sweep.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_timebase.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/tests/test_validate.py +0 -0
- {smolpy-1.9.1.dev4 → smolpy-1.9.1.dev6}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: smolpy
|
|
3
|
-
Version: 1.9.1.
|
|
3
|
+
Version: 1.9.1.dev6
|
|
4
4
|
Summary: Network simulation DSL and discrete-event simulator
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -482,7 +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,
|
|
485
|
+
| `ns3` (in progress) | ns-3's IPv4/UDP stack, from C++ | Ethernet so far: adapters, switches, every traffic pattern, IMIX, 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` |
|
|
486
486
|
|
|
487
487
|
```python
|
|
488
488
|
result = net.simulate(duration=60_000, backend="rust") # one run
|
|
@@ -454,7 +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,
|
|
457
|
+
| `ns3` (in progress) | ns-3's IPv4/UDP stack, from C++ | Ethernet so far: adapters, switches, every traffic pattern, IMIX, 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` |
|
|
458
458
|
|
|
459
459
|
```python
|
|
460
460
|
result = net.simulate(duration=60_000, backend="rust") # one run
|
|
@@ -106,7 +106,9 @@ smolpy backends # list backends and their capabiliti
|
|
|
106
106
|
|
|
107
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.
|
|
108
108
|
|
|
109
|
-
**Seed.** The `simulate` statement's `seed` maps to ns-3's RNG seed/run configuration, so seeded runs are reproducible on both backends.
|
|
109
|
+
**Seed.** ~~The `simulate` statement's `seed` maps to ns-3's RNG seed/run configuration, so seeded runs are reproducible on both backends.~~ *As built (2026-11-16):* random traffic is not drawn by ns-3's generators. The Python side draws every frame of a random flow from the flow's own stream, the one Model Semantics §6 seeds from the run seed and its source id. It uses the reference engine's generator, order of draws and formulas, so the instants and sizes are the same as SimPy's. ns-3 sends the listed frames.
|
|
110
|
+
- **Why.** With the same seed, a stochastic scenario is the same run on SimPy and ns-3. Any difference is then the network's, not the traffic's, and the comparison is exact rather than statistical.
|
|
111
|
+
- **Cost.** Constant flows of fixed-size frames are still generated in C++. Only random flows and IMIX sizes are listed, one pair of integers per frame.
|
|
110
112
|
|
|
111
113
|
**Time.** *Added by the ADR-0007 revision of 2026-11-14.* The generator keeps ns-3's `Time` resolution at 1 ns and writes every time as integer nanoseconds, rounded by the rules of [Model Semantics §1](../model-semantics.md#1-time-and-units): delays, cycles, sampling instants and the end of the run. So ns-3 and the other engines share one clock. Timings that ns-3's own device and TCP/IP models compute are ns-3's, which is why ns-3 is compared under ADR-0009's high-fidelity rules.
|
|
112
114
|
|
|
@@ -221,7 +223,12 @@ ns-3.49's CSMA is a shared bus: the two ends of a link wait for each other, and
|
|
|
221
223
|
- **CSMA as planned.** Its differences from the other engines would come from half duplex.
|
|
222
224
|
- **`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
225
|
|
|
224
|
-
**First results** *(2026-11-16)*.
|
|
226
|
+
**First results** *(2026-11-16)*. Everything Ethernet is in scope: adapters, switches and flows with every pattern, IMIX sizes and 802.1Q priorities.
|
|
227
|
+
- **Deterministic scenarios.** `line`, `switching` and `bridging` 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.
|
|
228
|
+
- **Stochastic scenarios.** `random-load` and `groups`, with Poisson, bursty and batch arrivals, IMIX and priorities, are bit for bit the same as SimPy's with the same seed, because the frames are drawn from the same streams. With other seeds they agree statistically.
|
|
229
|
+
- **Consequence.** The suite compares ns-3 exactly, like Rust. ADR-0009's high-fidelity rules remain for TCP.
|
|
230
|
+
|
|
231
|
+
ns-3 adds a priority to a frame as a packet tag. Its device then adds the 802.1Q tag's 4 B and serves its egress queue strictly by priority, or FIFO on a switch with `qos="fifo"`.
|
|
225
232
|
|
|
226
233
|
**The ns-3 base image, as built** *(2026-11-16)*:
|
|
227
234
|
- `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`.
|
|
@@ -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. These rules remain for TCP, where ns-3's stack is meant to differ. |
|
|
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. |
|
|
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 adapters, switches
|
|
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. 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. |
|
|
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.
|
|
@@ -176,11 +176,12 @@ ns-3 cannot be installed with `pip`, so the backend ships as a container image,
|
|
|
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.**
|
|
179
|
-
- **Ethernet: done.** `backend="ns3"` runs adapters, switches and
|
|
179
|
+
- **Ethernet: done.** `backend="ns3"` runs adapters, switches and flows with every pattern, IMIX and 802.1Q priorities, with the six Ethernet metrics, on ns-3's IPv4/UDP stack.
|
|
180
180
|
- It runs over SMOL's own full-duplex Ethernet device, because ns-3's CSMA is half duplex (ADR-0004).
|
|
181
|
-
-
|
|
181
|
+
- Random traffic is drawn from the reference engine's streams.
|
|
182
|
+
- Every Ethernet scenario of the suite is bit-exact with SimPy. For the stochastic ones that holds with the same seed.
|
|
182
183
|
- CI runs the backend in the base image.
|
|
183
|
-
- **Next:**
|
|
184
|
+
- **Next:** Modbus and MQTT over ns-3's TCP, then PROFINET.
|
|
184
185
|
|
|
185
186
|
**Exit criteria:**
|
|
186
187
|
|
|
@@ -160,8 +160,8 @@ 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
|
|
164
|
-
802.1Q priorities
|
|
163
|
+
So far it runs Ethernet: adapters, switches and flows with every pattern,
|
|
164
|
+
IMIX and 802.1Q priorities. The protocols follow in Phase 6.
|
|
165
165
|
"""
|
|
166
166
|
|
|
167
167
|
name = "ns3"
|
|
@@ -193,7 +193,7 @@ class Ns3Backend:
|
|
|
193
193
|
return Capabilities(
|
|
194
194
|
nodes=frozenset({"adapter", "switch"}),
|
|
195
195
|
traffic=frozenset({"flow"}),
|
|
196
|
-
patterns=
|
|
196
|
+
patterns=_PATTERNS,
|
|
197
197
|
metrics=frozenset(
|
|
198
198
|
{
|
|
199
199
|
"throughput",
|
|
@@ -204,7 +204,7 @@ class Ns3Backend:
|
|
|
204
204
|
"utilization",
|
|
205
205
|
}
|
|
206
206
|
),
|
|
207
|
-
|
|
207
|
+
features=frozenset({"imix"}),
|
|
208
208
|
notes={
|
|
209
209
|
kind: later
|
|
210
210
|
for kind in (
|
|
@@ -20,10 +20,12 @@ from __future__ import annotations
|
|
|
20
20
|
import glob
|
|
21
21
|
import hashlib
|
|
22
22
|
import os
|
|
23
|
+
import random
|
|
23
24
|
import shutil
|
|
24
25
|
import subprocess
|
|
25
26
|
import tempfile
|
|
26
27
|
import time
|
|
28
|
+
from collections.abc import Iterator
|
|
27
29
|
from dataclasses import dataclass
|
|
28
30
|
from fractions import Fraction
|
|
29
31
|
from importlib import resources
|
|
@@ -33,6 +35,7 @@ from typing import TYPE_CHECKING
|
|
|
33
35
|
from smolpy import model
|
|
34
36
|
from smolpy.model import timebase as tb
|
|
35
37
|
from smolpy.model.frames import IFG_BYTES
|
|
38
|
+
from smolpy.model.streams import source_ids, stream_seed
|
|
36
39
|
|
|
37
40
|
if TYPE_CHECKING:
|
|
38
41
|
from smolpy.core.network import SimulationResult
|
|
@@ -142,6 +145,59 @@ class _Sampler:
|
|
|
142
145
|
speed: Fraction = Fraction(0) # utilization: Mb/s into the target
|
|
143
146
|
|
|
144
147
|
|
|
148
|
+
def _strict(node: model.NodeSpec) -> bool:
|
|
149
|
+
"""Whether a node's egress queues serve priorities strictly."""
|
|
150
|
+
return not (isinstance(node, model.SwitchNode) and node.qos == "fifo")
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _sends(
|
|
154
|
+
flow: model.Flow, rng: random.Random, delay_ns: int, duration_ns: int
|
|
155
|
+
) -> Iterator[tuple[int, int]]:
|
|
156
|
+
"""Every frame of *flow* before *duration_ns*: its instant and size
|
|
157
|
+
(untagged, FCS included), drawn from *rng* in the order and with the
|
|
158
|
+
formulas of the reference engine's ``_traffic_gen``, so the frames are
|
|
159
|
+
the same as there."""
|
|
160
|
+
from smolpy.sim.engine import _resolve_size
|
|
161
|
+
|
|
162
|
+
def size() -> int:
|
|
163
|
+
return _resolve_size(flow.size, rng)
|
|
164
|
+
|
|
165
|
+
now = delay_ns
|
|
166
|
+
period = tb.interval_ns(flow.rate)
|
|
167
|
+
mean_ns = float(period)
|
|
168
|
+
if flow.pattern == "constant":
|
|
169
|
+
for at in tb.instants(delay_ns, period):
|
|
170
|
+
if at >= duration_ns:
|
|
171
|
+
return
|
|
172
|
+
yield at, size()
|
|
173
|
+
elif flow.pattern == "poisson":
|
|
174
|
+
while True:
|
|
175
|
+
now += tb.draw_ns(rng.expovariate(1.0 / mean_ns))
|
|
176
|
+
if now >= duration_ns:
|
|
177
|
+
return
|
|
178
|
+
yield now, size()
|
|
179
|
+
elif flow.pattern == "batch":
|
|
180
|
+
assert flow.batch is not None
|
|
181
|
+
group_ns = mean_ns * flow.batch.mean()
|
|
182
|
+
while True:
|
|
183
|
+
now += tb.draw_ns(rng.expovariate(1.0 / group_ns))
|
|
184
|
+
if now >= duration_ns:
|
|
185
|
+
return
|
|
186
|
+
for _ in range(flow.batch.draw(rng)):
|
|
187
|
+
yield now, size()
|
|
188
|
+
else: # bursty
|
|
189
|
+
quarter = Fraction(period) / 4
|
|
190
|
+
while True:
|
|
191
|
+
burst_len = max(1, int(rng.paretovariate(1.5)))
|
|
192
|
+
in_burst = tb.instants(now, quarter)
|
|
193
|
+
for _ in range(burst_len):
|
|
194
|
+
now = next(in_burst)
|
|
195
|
+
if now >= duration_ns:
|
|
196
|
+
return
|
|
197
|
+
yield now, size()
|
|
198
|
+
now += tb.draw_ns(mean_ns * burst_len * rng.uniform(0.3, 1.2))
|
|
199
|
+
|
|
200
|
+
|
|
145
201
|
def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
|
|
146
202
|
"""The input of ``smol-ns3``, and the samplers its output feeds."""
|
|
147
203
|
from smolpy.sim.engine import _topology_mac_table
|
|
@@ -173,6 +229,7 @@ def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
|
|
|
173
229
|
lines.append(
|
|
174
230
|
f"link {index[a.name]} {index[b.name]} {num} {den}"
|
|
175
231
|
f" {tb.propagation_ns(link.length_m)} {tb.transmission_ns(IFG_BYTES, link.speed_mbps)}"
|
|
232
|
+
f" {int(_strict(a))} {int(_strict(b))}"
|
|
176
233
|
)
|
|
177
234
|
neighbours[a.name].append((port_a, b.name))
|
|
178
235
|
neighbours[b.name].append((port_b, a.name))
|
|
@@ -192,18 +249,25 @@ def lower(scenario: model.Scenario) -> tuple[str, list[_Sampler]]:
|
|
|
192
249
|
lines.extend(f"static {index[name]} {mac} {port}" for mac, port in table.items())
|
|
193
250
|
|
|
194
251
|
sinks: list[str] = []
|
|
195
|
-
|
|
252
|
+
duration_ns = tb.ms_to_ns(scenario.run.duration_ms)
|
|
253
|
+
for t, source_id in zip(scenario.traffic, source_ids(scenario), strict=True):
|
|
196
254
|
if not isinstance(t, model.Flow):
|
|
197
255
|
raise ValueError(f"the ns3 backend does not support {t.kind} traffic")
|
|
198
256
|
if t.source not in has_link:
|
|
199
257
|
continue
|
|
200
258
|
dst = nodes[t.destination]
|
|
201
|
-
assert isinstance(dst, model.AdapterNode)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
259
|
+
assert isinstance(dst, model.AdapterNode)
|
|
260
|
+
delay_ns = tb.ms_to_ns(t.delay_ms)
|
|
261
|
+
ends = f"{index[t.source]} {dst.ip}"
|
|
262
|
+
if t.pattern == "constant" and isinstance(t.size, int):
|
|
263
|
+
num, den = _ratio(tb.interval_ns(t.rate))
|
|
264
|
+
payload = t.size - ETHERNET_BYTES - UDP_IP_BYTES
|
|
265
|
+
lines.append(f"flow {ends} {payload} {t.priority} {delay_ns} {num} {den}")
|
|
266
|
+
else:
|
|
267
|
+
rng = random.Random(stream_seed(scenario.run.seed, source_id))
|
|
268
|
+
sends = list(_sends(t, rng, delay_ns, duration_ns))
|
|
269
|
+
listed = " ".join(f"{at} {size - ETHERNET_BYTES - UDP_IP_BYTES}" for at, size in sends)
|
|
270
|
+
lines.append(f"sends {ends} {t.priority} {len(sends)} {listed}".rstrip())
|
|
207
271
|
if dst.name not in sinks:
|
|
208
272
|
sinks.append(dst.name)
|
|
209
273
|
lines.extend(f"sink {index[name]}" for name in sinks)
|
|
@@ -8,10 +8,15 @@
|
|
|
8
8
|
// duration <ns>
|
|
9
9
|
// adapter <mac> <ipv4> nodes, numbered from 0 in order
|
|
10
10
|
// switch
|
|
11
|
-
// link <a> <b> <speed num> <speed den> <propagation ns> <gap ns>
|
|
11
|
+
// link <a> <b> <speed num> <speed den> <propagation ns> <gap ns> <strict a> <strict b>
|
|
12
12
|
// static <switch> <mac> <port> a switch's MAC table at the start
|
|
13
|
-
// flow <src> <dst ipv4> <udp payload> <delay ns> <period num> <period den>
|
|
13
|
+
// flow <src> <dst ipv4> <udp payload> <priority> <delay ns> <period num> <period den>
|
|
14
|
+
// sends <src> <dst ipv4> <priority> <n> <t ns> <udp payload> ...
|
|
14
15
|
// sink <node> a node that receives flows
|
|
16
|
+
//
|
|
17
|
+
// A flow is a constant one of fixed-size frames; "sends" lists every frame of
|
|
18
|
+
// any other flow, its instant and size drawn by smolpy.ns3 from the flow's
|
|
19
|
+
// random stream exactly as the reference engine draws them.
|
|
15
20
|
// observe <kind> <target> <period num> <period den> <device>...
|
|
16
21
|
//
|
|
17
22
|
// Link i has the devices 2i (on a) and 2i + 1 (on b); a node's ports are
|
|
@@ -25,9 +30,11 @@
|
|
|
25
30
|
// What ns-3 contributes is its IPv4/UDP stack; the link and the switch are
|
|
26
31
|
// SMOL's own, to give the same Ethernet as the other engines:
|
|
27
32
|
// - SmolDevice: a full-duplex Ethernet port (ns-3's CSMA is half duplex).
|
|
28
|
-
// A frame is its IP packet plus header and FCS (18 B), at least 64 B
|
|
29
|
-
//
|
|
30
|
-
//
|
|
33
|
+
// A frame is its IP packet plus header and FCS (18 B), at least 64 B, and
|
|
34
|
+
// an 802.1Q tag (4 B) with a priority above 0; it occupies the wire for
|
|
35
|
+
// preamble, SFD and frame, and the next frame waits for the 12 B gap
|
|
36
|
+
// (ADR-0010). The egress queue is unbounded and serves priorities strictly,
|
|
37
|
+
// FIFO within one, or is plain FIFO on a switch with qos=fifo.
|
|
31
38
|
// - SmolSwitch: store-and-forward, learning, flooding unknown destinations to
|
|
32
39
|
// every port but the one a frame came in on, dropping hairpins.
|
|
33
40
|
// - Neighbour caches start full: SMOL models no ARP.
|
|
@@ -37,6 +44,7 @@
|
|
|
37
44
|
#include "ns3/network-module.h"
|
|
38
45
|
|
|
39
46
|
#include <algorithm>
|
|
47
|
+
#include <array>
|
|
40
48
|
#include <cstdint>
|
|
41
49
|
#include <deque>
|
|
42
50
|
#include <fstream>
|
|
@@ -53,6 +61,7 @@ using namespace ns3;
|
|
|
53
61
|
using u128 = unsigned __int128;
|
|
54
62
|
|
|
55
63
|
constexpr uint64_t ETHERNET_BYTES = 14 + 4; // header and FCS
|
|
64
|
+
constexpr uint64_t VLAN_TAG_BYTES = 4;
|
|
56
65
|
constexpr uint64_t MIN_FRAME_BYTES = 64;
|
|
57
66
|
constexpr uint64_t PREAMBLE_SFD_BYTES = 8;
|
|
58
67
|
constexpr uint64_t WIRE_OVERHEAD_BITS = (8 + 12) * 8; // preamble, SFD and gap
|
|
@@ -157,6 +166,56 @@ class OriginTag : public Tag
|
|
|
157
166
|
uint64_t m_created;
|
|
158
167
|
};
|
|
159
168
|
|
|
169
|
+
// The 802.1Q priority (PCP) of a flow's frames, above 0.
|
|
170
|
+
class PriorityTag : public Tag
|
|
171
|
+
{
|
|
172
|
+
public:
|
|
173
|
+
PriorityTag(uint8_t priority = 0)
|
|
174
|
+
: m_priority(priority)
|
|
175
|
+
{
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static TypeId GetTypeId()
|
|
179
|
+
{
|
|
180
|
+
static TypeId tid =
|
|
181
|
+
TypeId("smol::PriorityTag").SetParent<Tag>().AddConstructor<PriorityTag>();
|
|
182
|
+
return tid;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
TypeId GetInstanceTypeId() const override
|
|
186
|
+
{
|
|
187
|
+
return GetTypeId();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
uint32_t GetSerializedSize() const override
|
|
191
|
+
{
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
void Serialize(TagBuffer i) const override
|
|
196
|
+
{
|
|
197
|
+
i.WriteU8(m_priority);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
void Deserialize(TagBuffer i) override
|
|
201
|
+
{
|
|
202
|
+
m_priority = i.ReadU8();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
void Print(std::ostream& os) const override
|
|
206
|
+
{
|
|
207
|
+
os << "priority=" << int(m_priority);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
uint8_t Priority() const
|
|
211
|
+
{
|
|
212
|
+
return m_priority;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private:
|
|
216
|
+
uint8_t m_priority;
|
|
217
|
+
};
|
|
218
|
+
|
|
160
219
|
struct Frame
|
|
161
220
|
{
|
|
162
221
|
Ptr<Packet> packet;
|
|
@@ -164,6 +223,7 @@ struct Frame
|
|
|
164
223
|
Mac48Address dst;
|
|
165
224
|
uint16_t protocol = 0;
|
|
166
225
|
uint64_t bytes = 0;
|
|
226
|
+
uint8_t priority = 0;
|
|
167
227
|
};
|
|
168
228
|
|
|
169
229
|
struct Window
|
|
@@ -187,11 +247,16 @@ class SmolDevice : public NetDevice
|
|
|
187
247
|
return tid;
|
|
188
248
|
}
|
|
189
249
|
|
|
190
|
-
void Configure(uint64_t speedNum,
|
|
250
|
+
void Configure(uint64_t speedNum,
|
|
251
|
+
uint64_t speedDen,
|
|
252
|
+
uint64_t gapNs,
|
|
253
|
+
bool strict,
|
|
254
|
+
Ptr<SmolChannel> channel)
|
|
191
255
|
{
|
|
192
256
|
m_speedNum = speedNum;
|
|
193
257
|
m_speedDen = speedDen;
|
|
194
258
|
m_gapNs = gapNs;
|
|
259
|
+
m_strict = strict;
|
|
195
260
|
m_channel = channel;
|
|
196
261
|
}
|
|
197
262
|
|
|
@@ -207,7 +272,8 @@ class SmolDevice : public NetDevice
|
|
|
207
272
|
// A frame for the egress queue: sent now if the port is idle.
|
|
208
273
|
void Enqueue(Frame frame)
|
|
209
274
|
{
|
|
210
|
-
m_queue.push_back(std::move(frame));
|
|
275
|
+
m_queue[m_strict ? frame.priority : 0].push_back(std::move(frame));
|
|
276
|
+
++m_queued;
|
|
211
277
|
if (!m_busy)
|
|
212
278
|
{
|
|
213
279
|
StartNext();
|
|
@@ -216,7 +282,7 @@ class SmolDevice : public NetDevice
|
|
|
216
282
|
|
|
217
283
|
uint64_t QueueLength() const
|
|
218
284
|
{
|
|
219
|
-
return
|
|
285
|
+
return m_queued; // the frame on the wire is not queued
|
|
220
286
|
}
|
|
221
287
|
|
|
222
288
|
uint64_t bitsSent = 0; // frame bits whose transmission has completed
|
|
@@ -313,7 +379,13 @@ class SmolDevice : public NetDevice
|
|
|
313
379
|
uint16_t protocol) override
|
|
314
380
|
{
|
|
315
381
|
Frame frame;
|
|
316
|
-
|
|
382
|
+
PriorityTag tag;
|
|
383
|
+
if (packet->PeekPacketTag(tag))
|
|
384
|
+
{
|
|
385
|
+
frame.priority = tag.Priority();
|
|
386
|
+
}
|
|
387
|
+
frame.bytes = std::max(MIN_FRAME_BYTES, packet->GetSize() + ETHERNET_BYTES) +
|
|
388
|
+
(frame.priority > 0 ? VLAN_TAG_BYTES : 0);
|
|
317
389
|
frame.packet = packet;
|
|
318
390
|
frame.src = Mac48Address::ConvertFrom(source);
|
|
319
391
|
frame.dst = Mac48Address::ConvertFrom(dest);
|
|
@@ -357,7 +429,10 @@ class SmolDevice : public NetDevice
|
|
|
357
429
|
m_channel = nullptr;
|
|
358
430
|
m_node = nullptr;
|
|
359
431
|
m_rx = MakeNullCallback<bool, Ptr<NetDevice>, Ptr<const Packet>, uint16_t, const Address&>();
|
|
360
|
-
m_queue
|
|
432
|
+
for (auto& q : m_queue)
|
|
433
|
+
{
|
|
434
|
+
q.clear();
|
|
435
|
+
}
|
|
361
436
|
m_sending = Frame();
|
|
362
437
|
NetDevice::DoDispose();
|
|
363
438
|
}
|
|
@@ -380,8 +455,13 @@ class SmolDevice : public NetDevice
|
|
|
380
455
|
void StartNext()
|
|
381
456
|
{
|
|
382
457
|
m_busy = true;
|
|
383
|
-
|
|
384
|
-
m_queue.
|
|
458
|
+
// the highest priority first, FIFO within one
|
|
459
|
+
auto q = std::find_if(m_queue.rbegin(), m_queue.rend(), [](const auto& c) {
|
|
460
|
+
return !c.empty();
|
|
461
|
+
});
|
|
462
|
+
m_sending = std::move(q->front());
|
|
463
|
+
q->pop_front();
|
|
464
|
+
--m_queued;
|
|
385
465
|
uint64_t now = Simulator::Now().GetNanoSeconds();
|
|
386
466
|
uint64_t gap = m_freeAt > now ? m_freeAt - now : 0; // the gap after the last frame
|
|
387
467
|
Simulator::Schedule(NanoSeconds(gap + TransmissionNs(m_sending.bytes)),
|
|
@@ -402,7 +482,9 @@ class SmolDevice : public NetDevice
|
|
|
402
482
|
uint64_t m_speedNum = 1;
|
|
403
483
|
uint64_t m_speedDen = 1;
|
|
404
484
|
uint64_t m_gapNs = 0;
|
|
405
|
-
|
|
485
|
+
bool m_strict = true;
|
|
486
|
+
std::array<std::deque<Frame>, 8> m_queue; // by priority; all in 0 if not strict
|
|
487
|
+
uint64_t m_queued = 0;
|
|
406
488
|
Frame m_sending;
|
|
407
489
|
bool m_busy = false;
|
|
408
490
|
uint64_t m_freeAt = 0; // the end of the gap after the last frame
|
|
@@ -478,7 +560,7 @@ SmolDevice::TransmitComplete()
|
|
|
478
560
|
m_channel->Transmit(this, std::move(m_sending));
|
|
479
561
|
m_sending = Frame();
|
|
480
562
|
m_busy = false;
|
|
481
|
-
if (
|
|
563
|
+
if (m_queued > 0)
|
|
482
564
|
{
|
|
483
565
|
StartNext();
|
|
484
566
|
}
|
|
@@ -563,14 +645,31 @@ class SmolFlow : public Application
|
|
|
563
645
|
return tid;
|
|
564
646
|
}
|
|
565
647
|
|
|
566
|
-
|
|
648
|
+
// a constant flow of fixed-size frames
|
|
649
|
+
void Configure(Ipv4Address dst,
|
|
650
|
+
uint8_t priority,
|
|
651
|
+
uint32_t payload,
|
|
652
|
+
Instants instants,
|
|
653
|
+
uint64_t stopNs)
|
|
567
654
|
{
|
|
568
655
|
m_dst = dst;
|
|
656
|
+
m_priority = priority;
|
|
569
657
|
m_payload = payload;
|
|
570
658
|
m_instants = instants;
|
|
571
659
|
m_stopNs = stopNs;
|
|
572
660
|
}
|
|
573
661
|
|
|
662
|
+
// any other flow: every frame, its instant and UDP payload
|
|
663
|
+
void Configure(Ipv4Address dst,
|
|
664
|
+
uint8_t priority,
|
|
665
|
+
std::vector<std::pair<uint64_t, uint32_t>> sends)
|
|
666
|
+
{
|
|
667
|
+
m_dst = dst;
|
|
668
|
+
m_priority = priority;
|
|
669
|
+
m_sends = std::move(sends);
|
|
670
|
+
m_listed = true;
|
|
671
|
+
}
|
|
672
|
+
|
|
574
673
|
private:
|
|
575
674
|
void StartApplication() override
|
|
576
675
|
{
|
|
@@ -586,28 +685,66 @@ class SmolFlow : public Application
|
|
|
586
685
|
|
|
587
686
|
void ScheduleNext()
|
|
588
687
|
{
|
|
589
|
-
uint64_t t
|
|
590
|
-
if (
|
|
688
|
+
uint64_t t;
|
|
689
|
+
if (m_listed)
|
|
690
|
+
{
|
|
691
|
+
if (m_next == m_sends.size())
|
|
692
|
+
{
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
t = m_sends[m_next].first;
|
|
696
|
+
}
|
|
697
|
+
else
|
|
591
698
|
{
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
699
|
+
t = m_instants.Next();
|
|
700
|
+
if (t >= m_stopNs)
|
|
701
|
+
{
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
595
704
|
}
|
|
705
|
+
Simulator::Schedule(NanoSeconds(t - Simulator::Now().GetNanoSeconds()),
|
|
706
|
+
&SmolFlow::Send,
|
|
707
|
+
this);
|
|
596
708
|
}
|
|
597
709
|
|
|
598
|
-
void
|
|
710
|
+
void SendOne(uint32_t payload)
|
|
599
711
|
{
|
|
600
|
-
Ptr<Packet> packet = Create<Packet>(
|
|
712
|
+
Ptr<Packet> packet = Create<Packet>(payload);
|
|
601
713
|
packet->AddPacketTag(OriginTag(Simulator::Now().GetNanoSeconds()));
|
|
714
|
+
if (m_priority > 0)
|
|
715
|
+
{
|
|
716
|
+
packet->AddPacketTag(PriorityTag(m_priority));
|
|
717
|
+
}
|
|
602
718
|
m_socket->Send(packet);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
void Send()
|
|
722
|
+
{
|
|
723
|
+
if (m_listed)
|
|
724
|
+
{
|
|
725
|
+
// a batch: every frame of this instant, back to back
|
|
726
|
+
uint64_t now = Simulator::Now().GetNanoSeconds();
|
|
727
|
+
while (m_next < m_sends.size() && m_sends[m_next].first == now)
|
|
728
|
+
{
|
|
729
|
+
SendOne(m_sends[m_next++].second);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
else
|
|
733
|
+
{
|
|
734
|
+
SendOne(m_payload);
|
|
735
|
+
}
|
|
603
736
|
ScheduleNext();
|
|
604
737
|
}
|
|
605
738
|
|
|
606
739
|
Ptr<Socket> m_socket;
|
|
607
740
|
Ipv4Address m_dst;
|
|
741
|
+
uint8_t m_priority = 0;
|
|
608
742
|
uint32_t m_payload = 0;
|
|
609
743
|
Instants m_instants;
|
|
610
744
|
uint64_t m_stopNs = 0;
|
|
745
|
+
bool m_listed = false;
|
|
746
|
+
std::vector<std::pair<uint64_t, uint32_t>> m_sends;
|
|
747
|
+
std::size_t m_next = 0;
|
|
611
748
|
};
|
|
612
749
|
|
|
613
750
|
NS_OBJECT_ENSURE_REGISTERED(SmolFlow);
|
|
@@ -750,7 +887,8 @@ Run(std::istream& in, std::ostream& out)
|
|
|
750
887
|
uint64_t speedDen;
|
|
751
888
|
uint64_t propagationNs;
|
|
752
889
|
uint64_t gapNs;
|
|
753
|
-
|
|
890
|
+
int strict[2];
|
|
891
|
+
s >> a >> b >> speedNum >> speedDen >> propagationNs >> gapNs >> strict[0] >> strict[1];
|
|
754
892
|
if (!s || a >= nodes.GetN() || b >= nodes.GetN())
|
|
755
893
|
{
|
|
756
894
|
Fail("bad link: " + line);
|
|
@@ -761,7 +899,7 @@ Run(std::istream& in, std::ostream& out)
|
|
|
761
899
|
for (int e = 0; e < 2; ++e)
|
|
762
900
|
{
|
|
763
901
|
Ptr<SmolDevice> d = CreateObject<SmolDevice>();
|
|
764
|
-
d->Configure(speedNum, speedDen, gapNs, channel);
|
|
902
|
+
d->Configure(speedNum, speedDen, gapNs, strict[e] != 0, channel);
|
|
765
903
|
Ptr<Node> node = nodes.Get(at[e]);
|
|
766
904
|
if (isSwitch[at[e]])
|
|
767
905
|
{
|
|
@@ -798,7 +936,7 @@ Run(std::istream& in, std::ostream& out)
|
|
|
798
936
|
s >> sw >> mac >> port;
|
|
799
937
|
switches[switchOf[sw]].table[MacKey(Mac48Address(mac.c_str()))] = port;
|
|
800
938
|
}
|
|
801
|
-
else if (word == "flow" || word == "sink" || word == "observe")
|
|
939
|
+
else if (word == "flow" || word == "sends" || word == "sink" || word == "observe")
|
|
802
940
|
{
|
|
803
941
|
break; // the network is complete: IPv4 and neighbour caches come first
|
|
804
942
|
}
|
|
@@ -854,21 +992,40 @@ Run(std::istream& in, std::ostream& out)
|
|
|
854
992
|
{
|
|
855
993
|
continue;
|
|
856
994
|
}
|
|
857
|
-
if (word == "flow")
|
|
995
|
+
if (word == "flow" || word == "sends")
|
|
858
996
|
{
|
|
859
997
|
uint32_t src;
|
|
860
998
|
std::string dst;
|
|
861
|
-
uint32_t
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
uint64_t den;
|
|
865
|
-
s >> src >> dst >> payload >> delayNs >> num >> den;
|
|
866
|
-
if (!s || src >= nodes.GetN() || !portOf[src])
|
|
999
|
+
uint32_t priority;
|
|
1000
|
+
Ptr<SmolFlow> flow = CreateObject<SmolFlow>();
|
|
1001
|
+
if (word == "flow")
|
|
867
1002
|
{
|
|
868
|
-
|
|
1003
|
+
uint32_t payload;
|
|
1004
|
+
uint64_t delayNs;
|
|
1005
|
+
uint64_t num;
|
|
1006
|
+
uint64_t den;
|
|
1007
|
+
s >> src >> dst >> payload >> priority >> delayNs >> num >> den;
|
|
1008
|
+
flow->Configure(Ipv4Address(dst.c_str()),
|
|
1009
|
+
priority,
|
|
1010
|
+
payload,
|
|
1011
|
+
Instants(delayNs, num, den),
|
|
1012
|
+
durationNs);
|
|
1013
|
+
}
|
|
1014
|
+
else
|
|
1015
|
+
{
|
|
1016
|
+
std::size_t n;
|
|
1017
|
+
s >> src >> dst >> priority >> n;
|
|
1018
|
+
std::vector<std::pair<uint64_t, uint32_t>> sends(n);
|
|
1019
|
+
for (auto& send : sends)
|
|
1020
|
+
{
|
|
1021
|
+
s >> send.first >> send.second;
|
|
1022
|
+
}
|
|
1023
|
+
flow->Configure(Ipv4Address(dst.c_str()), priority, std::move(sends));
|
|
1024
|
+
}
|
|
1025
|
+
if (!s || src >= nodes.GetN() || !portOf[src] || priority > 7)
|
|
1026
|
+
{
|
|
1027
|
+
Fail("bad " + word + ": " + line.substr(0, 200));
|
|
869
1028
|
}
|
|
870
|
-
Ptr<SmolFlow> flow = CreateObject<SmolFlow>();
|
|
871
|
-
flow->Configure(Ipv4Address(dst.c_str()), payload, Instants(delayNs, num, den), durationNs);
|
|
872
1029
|
nodes.Get(src)->AddApplication(flow);
|
|
873
1030
|
flow->SetStartTime(NanoSeconds(0));
|
|
874
1031
|
}
|